<body>
<p>The toString() method converts a number to a string.</p>
<p id="demo"></p>
<script>
var x = 123;
document.getElementById("demo").innerHTML =
x.toString() + "<br />" + // returns 123 from variable x
(123).toString() + "<br />" +
// returns 123 from literal 123
(100 + 23).toString(); // returns 123 from expression 100 + 23
</script>
</body>
|
The toString() method converts a number to a string.
|