BigInt

Tags
javascript
Created
Apr 16, 2018 3:46 AM

https://v8.dev/blog/bigint

可用于任意大整数

不能表示分数只表示整数

json 没有这个类型,不能 json 序列化

typeof 123n === 'bigint'

不能和 Number 混用

BigInt.asIntN/BigInt.asUintN: 包装为指定位数的 BigInt,超过最大值时结果为 0n

转换:

Convert to
Explicit conversion
Coercion (implicit conversion)
boolean
Boolean(0n) → false
!0n → true
Boolean(int) → true
!int → false
number
Number(int) → OK
+int → TypeError
string
String(int) → OK
''+int → OK
SuperMade with Super