The toString() method converts a number to a string.
The toString() method converts a number to a string.
number.toString(radix)
Parameter | Require | Description |
---|---|---|
radix | Optional. | base to use for representing a numeric value. |
The radix Must be an integer between 2 and 36.
A String, representing a number
Convert a number to a string:
//display the formatted number. var num = 15;/*from ww w .j a v a 2 s . co m*/ var n = num.toString(); console.log(n); //Convert a number to a string, using different bases: 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 + "\n" + b + "\n" + c + "\n" + d; console.log(n);