Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

TypeScript | String toString() Method

  • Last Updated : 18 Jun, 2020

The toString() is an inbuilt function in TypeScript which is used to return a string representing the specified object.

Syntax: 

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

string.toString( ) 

Parameter: This methods does not accept any parameter. 
Return Value: This method returns the string representing the specified object. 
Below examples illustrate the String toString() method in TypeScript

Example 1: 



JavaScript




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

Output: 

Geeksforgeeks - Best Platform

Example 2: 

JavaScript




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

Output: 

TypeScript - String toString()
My Personal Notes arrow_drop_up
Recommended Articles
Page :