Tutorialspoint.dev

JavaScript | string.toString()

The string.toString() is an inbuilt function in JavaScript which is used to return the given string itself.
Syntax:

string.toString()

Parameters: It does not accept any parameter.
Return Values: It returns a new string represent the given string object.
JavaScript code to show the working of string.toString() function:

<script>
  
    // Taking a string as input and printing it
    // with the help of string.toString() function
    var a = new String("GeeksforGeeks");
    document.write(a.toString());
  
</script>

Output:

GeeksforGeeks


This article is attributed to GeeksforGeeks.org

leave a comment

code

0 Comments

load comments

Subscribe to Our Newsletter