Thursday, October 9, 2025
HomeLanguagesJavascriptTypeScript String toString() Method

TypeScript String toString() Method

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

Syntax: 

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 = "Geeksforneveropen - Best Platform"
  
    // use of String toString() Method
    var newstr = str.toString() 
    console.log(newstr);
</script>


Output: 

Geeksforneveropen - 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()
RELATED ARTICLES

Most Popular

Dominic
32342 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6712 POSTS0 COMMENTS
Nicole Veronica
11875 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11937 POSTS0 COMMENTS
Shaida Kate Naidoo
6833 POSTS0 COMMENTS
Ted Musemwa
7092 POSTS0 COMMENTS
Thapelo Manthata
6786 POSTS0 COMMENTS
Umr Jansen
6789 POSTS0 COMMENTS