mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 07:17:50 +00:00
34 lines
792 B
JavaScript
34 lines
792 B
JavaScript
import baseGetTag from './.internal/baseGetTag.js';
|
|
import isObjectLike from './isObjectLike.js';
|
|
|
|
/**
|
|
* Checks if `value` is classified as a `Number` primitive or object.
|
|
*
|
|
* **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
|
|
* classified as numbers, use the `Number.isFinite` method.
|
|
*
|
|
* @since 0.1.0
|
|
* @category Lang
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is a number, else `false`.
|
|
* @example
|
|
*
|
|
* isNumber(3);
|
|
* // => true
|
|
*
|
|
* isNumber(Number.MIN_VALUE);
|
|
* // => true
|
|
*
|
|
* isNumber(Infinity);
|
|
* // => true
|
|
*
|
|
* isNumber('3');
|
|
* // => false
|
|
*/
|
|
function isNumber(value) {
|
|
return typeof value == 'number' ||
|
|
(isObjectLike(value) && baseGetTag(value) == '[object Number]');
|
|
}
|
|
|
|
export default isNumber;
|