TypeScript | String valueOf() Method

The valueOf() is an inbuilt function in TypeScript which 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



filter_none

edit
close

play_arrow

link
brightness_4
code

<script>
    // Original strings
    var str = "Geeksforgeeks - Best Platform"
  
    // use of String valueOf() Method
    var newstr = str.valueOf() 
    console.log(newstr);
</script>

chevron_right


Output: 

Geeksforgeeks - Best Platform

Example 2: 

JavaScript

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output: 

TypeScript - String valueOf()

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.