字符串和数字相加的常见错误 2
- <!DOCTYPE html>
- <html>
- <body>
- <h1>JavaScript 数字</h1>
- <p>一个常见的错误是期望这个结果是 102030:</p>
- <p id="demo"></p>
- <script>
- var x = 10;
- var y = 20;
- var z = "30";
- var result = x + y + z;
- document.getElementById("demo").innerHTML = result;
- </script>
- </body>
- </html>