Home >>JavaScript String Methods >JavaScript String toString() Method
JavaScript toString() method is used to return the value of a given input String object. It is used with a number num using the ‘.’ operator. It converts the num to a string.
Syntax:string.toString()
Method | Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
toString() | Yes | Yes | Yes | Yes | Yes |
<html> <body> <p>Click the button to see the Output.</p> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() { var str = "PHPTPOINT!!"; var res = str.toString(); document.getElementById("demo").innerHTML = res; } </script> </body> </html>
Click the button to see the Output.