Giter VIP home page Giter VIP logo

Comments (2)

Hiker9527 avatar Hiker9527 commented on June 16, 2024
isNaN: function(value){
  return isNumber(value) && isNaN(value);
}

我不知道你这里的isNaN是如何实现的,如果也是Object.prototype.toString()的话NaN和Number都会返回[object Number],所以我这样调用isNan(number)会不会也返回true。这样来说,你的isNumber()也是有问题的。

from underscore-analysis.

zhangxiang958 avatar zhangxiang958 commented on June 16, 2024

@shawnWangxx isNaN 是一个全局函数, 在 ES6 中需要先判断变量类型是否是数字类型, 如果是数字类型,
isNaN 才会返回 true, 所以 isNaN 中先判断数字类型是需要的, isNumber 是使用 Object.prototype.toString.call 来判断数字类型的, NaN 与数字类型都是返回了 [object Number].

抱歉回复晚了

from underscore-analysis.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.