TypeScript | String Constructor Property

The Constructor Property() in TypeScript which is used to returns a reference to the String function that created the object. 
Syntax:

string.constructor 

Return Value: This method returns the reference to the String function that created the object. 
Below example illustrate the  String Constructor Property in TypeScript

 Example 1: 

JavaScript

filter_none

edit
close

play_arrow

link
brightness_4
code

<script>
    // Original strings
    var str = "Geeksforgeeks - Best Platform"
   
    // use of Constructor Property
    var newstr = str.constructor 
    console.log("Return Value of constructor property:", newstr);
</script>

chevron_right


Output: 



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

Example 2: 

JavaScript

filter_none

edit
close

play_arrow

link
brightness_4
code

<script>
    // Original strings
    var str = new String("TypeScript - String Constructor Property"); 
   
    // use of Constructor Property
    var newstr = str.constructor 
    console.log(newstr);
</script>

chevron_right


Output: 

function String() { [native code] }

full-stack-img

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.