20.BigInt.html 699 B

123456789101112131415161718192021222324252627
  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. // BigInt 处理超大整数 精度不丢失
  11. // 9007199254740991 最大的安全整数
  12. let a = 9007199254740991n + 1n;
  13. console.log(9007199254740991n + 1n)
  14. console.log(9007199254740991n + 2n)
  15. console.log(9007199254740991n + 3n)
  16. // console.log(typeof a)
  17. // console.log(9007199254740991n +200n)
  18. // console.log(typeof BigInt(123))
  19. // console.log(typeof 123n)
  20. // console.log(9n > 55n)
  21. </script>
  22. </body>
  23. </html>