小编dlx*_*eon的帖子

为什么 lodash .isNumber 函数比 typeof value == 'number' 更复杂

LodashisNumber函数有一个额外的条件来检查值是否为数字。我不确定为什么需要这样做,在什么情况下仅使用是不够的typeof value == 'number'

function isNumber(value) {
  return typeof value == 'number' ||
    (isObjectLike(value) && getTag(value) == '[object Number]')
}
Run Code Online (Sandbox Code Playgroud)

https://github.com/lodash/lodash/blob/aa1d7d870d9cf84842ee23ff485fd24abf0ed3d1/isNumber.js

javascript lodash

4
推荐指数
2
解决办法
7039
查看次数

标签 统计

javascript ×1

lodash ×1