The toString()
method returns the value of a String object.
toString() |
Yes | Yes | Yes | Yes | Yes |
stringObject.toString();
None.
A string representing the value of a string.
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<script>
function myFunction() {<!-- w w w . j a va 2 s . c om-->
var str = "Hello World!";
var res = str.toString();
document.getElementById("demo").innerHTML = res;
}
</script>
</body>
</html>
The code above is rendered as follows: