Open In App

JavaScript String constructor Property

Last Updated : 16 Jul, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

The String constructor property in JavaScript is used to return the string constructor function for the object. The function which is returned by this property is just the reference to this function, not a string containing the function’s name. The JavaScript number constructor, string constructor, and boolean constructor return function Number() { [native code] }, function String() { [native code] } and function Boolean() { [native code] } respectively.

Syntax: 

string.constructor

Return Value:

  • function String() { [native code] }

Example 1: This example shows the basic use of the String constructor Property in Javascript.

JavaScript
function func() {
    let str = 'Geeks for Geeks';
    let value = str.constructor;
    console.log(value);
}
func(); 

Output:  

function String() { [native code] }

Example 2: This example uses the String constructor Property of Javascript.

JavaScript
function myGeeks() {
    let str = "Hello World!";

    console.log(str.constructor);
}
myGeeks()

Output
[Function: String]

Supported Browsers:

The browser supported by the String constructor property are listed below.

  • Google Chrome 1
  • Edge 12
  • Apple Safari 1
  • Firefox 1
  • Opera 3

Next Article

Similar Reads