使用 toString() 把数转换为字符串
- <!DOCTYPE html>
- <html>
- <body>
- <h2>JavaScript 数字方法</h2>
- <p>toString() 方法把数字转换为字符串。</p>
- <p id="demo"></p>
- <script>
- var x = 123;
- document.getElementById("demo").innerHTML =
- x.toString() + "<br>" +
- (123).toString() + "<br>" +
- (100 + 23).toString();
- </script>
- </body>
- </html>