Number 对象
const a = new Number(1)1. 静态属性
Number.POSITIVE_INFINITY // Infinity
Number.NEGATIVE_INFINITY // -Infinity
Number.NaN // NaN
Number.MAX_VALUE // 1.7976931348623157e+308
Number.MAX_VALUE < Infinity // true
Number.MIN_VALUE // 5e-324
Number.MIN_VALUE > 0 // true
Number.MAX_SAFE_INTEGER // 9007199254740991
Number.MIN_SAFE_INTEGER // -9007199254740991
Number.EPSILON // 代表一个极小量// 0.1 + 0.2 与 0.3 得到的结果是 false,这是由于二进制存储的原因
function withinErrorMargin (left, right) {
return Math.abs(left - right) < Number.EPSILON;
}
0.1 + 0.2 === 0.3 // false
withinErrorMargin(0.1 + 0.2, 0.3) // true2. 静态方法
3. 实例方法
最后更新于