time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

isNaN.js (911B)


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