数字和数字字符串相加也会产生连接的字符串
- <!DOCTYPE html>
- <html>
- <body>
- <h1>JavaScript 数字</h1>
- <p>如果数字和数字字符串相加,结果将是级联字符串:</p>
- <p id="demo"></p>
- <script>
- var x = 10;
- var y = "20";
- var z = x + y;
- document.getElementById("demo").innerHTML = z;
- </script>
- </body>
- </html>