Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80742 views
1
var isNumber = require('./isNumber');
2
3
/**
4
* Checks if `value` is `NaN`.
5
*
6
* **Note:** This method is not the same as [`isNaN`](https://es5.github.io/#x15.1.2.4)
7
* which returns `true` for `undefined` and other non-numeric values.
8
*
9
* @static
10
* @memberOf _
11
* @category Lang
12
* @param {*} value The value to check.
13
* @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
14
* @example
15
*
16
* _.isNaN(NaN);
17
* // => true
18
*
19
* _.isNaN(new Number(NaN));
20
* // => true
21
*
22
* isNaN(undefined);
23
* // => true
24
*
25
* _.isNaN(undefined);
26
* // => false
27
*/
28
function isNaN(value) {
29
// An `NaN` primitive is the only value that is not equal to itself.
30
// Perform the `toStringTag` check first to avoid errors with some host objects in IE.
31
return isNumber(value) && value != +value;
32
}
33
34
module.exports = isNaN;
35
36