Open In App

JavaScript String constructor Property

Last Updated : 29 May, 2023
Improve
Improve
Like Article
Like
Save
Share
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] }

Below are examples of the String constructor Property. 

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]

We have a complete list of Javascript string methods, to check those please go through this Javascript String Complete reference article.

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

  • Google Chrome 1 and above
  • Edge 12 and above
  • Apple Safari 1 and above
  • Firefox 1 and above
  • Opera 3 and above
  • Internet Explorer 3 and above

We have a Cheat Sheet on JavaScript where we covered all the important topics of JavaScript to check those please go through JavaScript Cheat Sheet – A Basic Guide to JavaScript.


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads