Open shfshanyue opened 3 years ago
Number.isNaN(NaN) isNaN(NaN) Number.isNaN('NaN') isNaN('NaN')
试了下 Number.isNaN('NaN')
是 false
,其他都是 true
还真没注意过,看了下 MDN,上面解释已经很明示了
isNaN
:
Return Value: true if the given value is NaN after being converted to a number; otherwise, false.
Number.isNaN
:
Return value: The boolean value true if the given value is a number with value NaN. Otherwise, false.
globalThis.isNaN
会对参数进行强制转换后判断是不是 NaN
,而 Number.isNaN
不会对输入的参数进行强制转换