Skip to content
Related Articles
Open in App
Not now

Related Articles

TypeScript | String valueOf() Method

Improve Article
Save Article
  • Last Updated : 17 Feb, 2021
Improve Article
Save Article

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




//language is TypeScript
 
    // Original strings
    var str = "Geeksforgeeks - Best Platform";
 
    // use of String valueOf() Method
    var newstr = str.valueOf()
    console.log(newstr);


Output:  

Geeksforgeeks - Best Platform

Example 2:  

JavaScript




// Language is TypeScript
 
    // Original strings
    var str = new String("TypeScript - String valueOf()");
 
    // use of String valueOf() Method
    var newstr = str.valueOf()
    console.log(newstr);


Output: 

TypeScript - String valueOf()
My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!