The valueOf() is an inbuilt function in TypeScript that is used to return the primitive value of a String object.
Syntax:
string.valueOf( )
Parameter: This method does not accept any parameter.
Return Value: This method returns the primitive value of a String object.
Below examples illustrate the String valueOf() method in TypeScript
Example 1:
JavaScript
var str = "Geeksforgeeks - Best Platform" ;
var newstr = str.valueOf()
console.log(newstr);
|
Output:
Geeksforgeeks - Best Platform
Example 2:
JavaScript
var str = new String( "TypeScript - String valueOf()" );
var newstr = str.valueOf()
console.log(newstr);
|
Output:
TypeScript - String valueOf()
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks 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!
Last Updated :
17 Feb, 2021
Like Article
Save Article