Open In App

TypeScript | String Constructor Property

Last Updated : 18 Jun, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

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




<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>


Output: 

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

Example 2: 

JavaScript




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


Output: 

function String() { [native code] }

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

Similar Reads