JavaScript 数字和字符串

  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4.  
  5. <h1>JavaScript 变量</h1>
  6.  
  7. <p>字符串用引号包围。</p>
  8. <p>数值不用引号包围。</p>
  9.  
  10. <p id="demo"></p>
  11.  
  12. <script>
  13. var pi = 3.14;
  14. var person = "Bill Gates";
  15. var answer = 'How are you!';
  16.  
  17. document.getElementById("demo").innerHTML =
  18. pi + "<br>" + person + "<br>" + answer;
  19. </script>
  20.  
  21. </body>
  22. </html>