Skip to content
Related Articles

Related Articles

Improve Article

JavaScript String constructor Property

  • Last Updated : 04 Sep, 2020
Geek Week

Below is the example of the String constructor Property.

  • Example:

    function func() { 
        var str = 'Geeks for Geeks'; 
        var value = str.constructor; 
  • Output:
    function String() { [native code] }

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 returns function Number() { [native code] }, function String() { [native code] } and function Boolean() { [native code] } respectively.



Return Value: function String() { [native code] }


<!DOCTYPE html>
        JavaScript String constructor Property
        Welcome to GeeksforGeeks
        Click the button to see string
        contructor property.
    <button onclick="myGeeks()">
        click me
    <p id="GFG"></p>
    <!--Script to use string constructor property-->
        function myGeeks() {
            var str = "Hello World!";
                    = str.constructor;

Before clicking the button:

After clicking the button:

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

  • Google Chrome
  • Apple Safari
  • Firefox
  • Opera
  • Edge

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it’s lowest price ever!

My Personal Notes arrow_drop_up
Recommended Articles
Page :