typeof (28) // number
typeof (3.14) // number
typeof (-140) // number
0.1 + 0.2 === 0.3 // false
0.1 + 0.2 === 0.30000000000000004 // true
特别的数字:NaN、Infinity、-Infinity、-0。
typeof (NaN) // number
typeof (Infinity) // number
typeof (-Infinity) // number
typeof (-0) // number
let scale = 0
let a = 1 / scale // Infinity
let b = 0 / scale // NaN
let c = -a // -Infinity
let d = 1 / c // -0
NaN:不是一个数字
⚠️注意:
undefined 转换为 Number 时为 NaN。
null 转换为 Number 时为 0。
NaN === NaN // false
undefined === undefined // true
Infinity === Infinity // true
-Infinity === -Infinity // true