We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
介绍一下NaN:
NaN
NaN === NaN
false
Object.is()
true
Object.is(NaN, NaN)
typeof NaN
"number"
parseInt()
parseFloat()
isNaN
JS
Number
(关于第三点,大家可以看一下我之前的一篇文章哟,里面的「第二补:JS类型检测-Object.is()和===的区别」有提到:读《三元-JS灵魂之问》总结,给自己的一份原生JS补给(上))
Object.is()和===的区别
实现一个isNaN:
对于isNaN的polyfill实现起来就比较简单了,只需要利用NaN不等于它自身的这一点即可:
polyfill
const isNaN = v => v !== v;
The text was updated successfully, but these errors were encountered:
No branches or pull requests
介绍一下NaN并实现一个isNaN
介绍一下NaN:
NaN
属性是代表非数字值的特殊值,该属性用于指示某个值不是数字;NaN
是不等于NaN
的,即NaN === NaN
的结果是false
;Object.is()
来比较两个NaN
结果是true
,即Object.is(NaN, NaN)
的结果是true
;typeof NaN
为"number"
;parseInt()
和parseFloat()
在不能解析指定的字符串时就返回这个值;isNaN
来判断一个变量是不是NaN
,它是JS
内置对象Number
上的静态方法。(关于第三点,大家可以看一下我之前的一篇文章哟,里面的「第二补:JS类型检测-
Object.is()和===的区别
」有提到:读《三元-JS灵魂之问》总结,给自己的一份原生JS补给(上))实现一个isNaN:
对于
isNaN
的polyfill
实现起来就比较简单了,只需要利用NaN
不等于它自身的这一点即可:The text was updated successfully, but these errors were encountered: