Comments (2)
isNaN: function(value){
return isNumber(value) && isNaN(value);
}
我不知道你这里的isNaN是如何实现的,如果也是Object.prototype.toString()
的话NaN和Number都会返回[object Number]
,所以我这样调用isNan(number)
会不会也返回true
。这样来说,你的isNumber()
也是有问题的。
from underscore-analysis.
@shawnWangxx isNaN 是一个全局函数, 在 ES6 中需要先判断变量类型是否是数字类型, 如果是数字类型,
isNaN 才会返回 true, 所以 isNaN 中先判断数字类型是需要的, isNumber 是使用 Object.prototype.toString.call 来判断数字类型的, NaN 与数字类型都是返回了 [object Number].
抱歉回复晚了
from underscore-analysis.
Related Issues (7)
- root 对象初始化 HOT 3
- underscore 中的变量缓存与继承
- 硬绑定代码性能优化
- 解读 cb 函数 HOT 5
- 模拟 ES6 rest 运算符 HOT 2
- for...in 循环的兼容性问题
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from underscore-analysis.