Javascript examples for Number:toString
The toString() method converts a number to a string.
number.toString(radix)
Parameter | Description |
---|---|
radix | Optional. Must be an integer between 2 and 36. |
radix value:
A String, representing a number
The following code shows how to Convert a number to a string:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w w w . j a v a 2s . c o m var num = 15; var a = num.toString(); var b = num.toString(2); var c = num.toString(8); var d = num.toString(16); var n = a + "<br>" + b + "<br>" + c + "<br>" + d; document.getElementById("demo").innerHTML=n; } </script> </body> </html>