声明(创建)数字

  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4.  
  5. <h2>JavaScript 数值</h2>
  6.  
  7. <p>写数值时用不用小数点均可:</p>
  8.  
  9. <p id="demo"></p>
  10.  
  11. <script>
  12. var x1 = 34.00;
  13. var x2 = 34;
  14. var x3 = 3.14;
  15.  
  16. document.getElementById("demo").innerHTML =
  17. x1 + "<br>" + x2 + "<br>" + x3;
  18. </script>
  19.  
  20. </body>
  21. </html>