5_数值型.html 686 B

1234567891011121314151617181920212223242526272829303132333435
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Document</title>
  7. </head>
  8. <body>
  9. <script>
  10. var a = 1;
  11. var b = 2;
  12. // 加法
  13. console.log(a+b);
  14. // 由于计算机计算精度问题 0.1 + 0.2 不等于0.3
  15. console.log(0.1+0.2);
  16. // 减法
  17. console.log(2-1);
  18. // 乘法
  19. console.log(2*2);
  20. // 除法
  21. console.log(4/2);
  22. // 取余
  23. console.log(5%2);
  24. // 括号
  25. console.log((2+1)*2);
  26. </script>
  27. </body>
  28. </html>