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:Ā
<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:Ā
<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] }