String toString() Method - Javascript String

Javascript examples for String:toString


The toString() method returns the value of a String object.



Return Value:

A String, representing the value of a string

The following code shows how to Return the value of a String object:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

function myFunction() {/*ww w. j  a  v  a2 m*/
    var str = "Hello World!";
    var res = str.toString();
    document.getElementById("demo").innerHTML = res;


Related Tutorials