对字符串和数字相加
- <!DOCTYPE html>
- <html>
- <body>
- <h1>JavaScript 运算符</h1>
- <p>对数字和字符串相加,会返回字符串。</p>
- <p id="demo"></p>
- <script>
- var x = 7 + 8;
- var y = "7" + 8;
- var z = "Hello" + 7;
- document.getElementById("demo").innerHTML =
- x + "<br>" + y + "<br>" + z;
- </script>
- </body>
- </html>