String toString() Method - Javascript String

Javascript examples for String:toString

Description

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

Parameters

None.

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>
<html>
<body>

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

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

<script>
function myFunction() {/*from w  w  w .ja v a  2  s . co m*/
    var str = "Hello World!";
    var res = str.toString();
    document.getElementById("demo").innerHTML = res;
}
</script>

</body>
</html>

Related Tutorials