Lodash isNumber
function has an extra condition to check if value is number. I'm not sure why is that required and in what case it is not enough to use just typeof value == 'number'
function isNumber(value) {
return typeof value == 'number' ||
(isObjectLike(value) && getTag(value) == '[object Number]')
}
https://github.com/lodash/lodash/blob/aa1d7d870d9cf84842ee23ff485fd24abf0ed3d1/isNumber.js
From your link:
Checks if
value
is classified as aNumber
primitive or object.
var n = new Number(3);
console.log(typeof n); // "object"
console.log(_.isNumber(n)); // true
MDN - Number:
The Number JavaScript object is a wrapper object allowing you to work with numerical values. A Number object is created using the Number() constructor. A primitive type object number is created using the Number() function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With