Sunday, December 29, 2024
Google search engine
HomeLanguagesJavascriptJavaScript String constructor Property

JavaScript String constructor Property

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.

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

RELATED ARTICLES

Most Popular

Recent Comments