Last change
on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
886 bytes
|
Line | |
---|
1 | var baseGetTag = require('./_baseGetTag'),
|
---|
2 | isObjectLike = require('./isObjectLike');
|
---|
3 |
|
---|
4 | /** `Object#toString` result references. */
|
---|
5 | var numberTag = '[object Number]';
|
---|
6 |
|
---|
7 | /**
|
---|
8 | * Checks if `value` is classified as a `Number` primitive or object.
|
---|
9 | *
|
---|
10 | * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are
|
---|
11 | * classified as numbers, use the `_.isFinite` method.
|
---|
12 | *
|
---|
13 | * @static
|
---|
14 | * @memberOf _
|
---|
15 | * @since 0.1.0
|
---|
16 | * @category Lang
|
---|
17 | * @param {*} value The value to check.
|
---|
18 | * @returns {boolean} Returns `true` if `value` is a number, else `false`.
|
---|
19 | * @example
|
---|
20 | *
|
---|
21 | * _.isNumber(3);
|
---|
22 | * // => true
|
---|
23 | *
|
---|
24 | * _.isNumber(Number.MIN_VALUE);
|
---|
25 | * // => true
|
---|
26 | *
|
---|
27 | * _.isNumber(Infinity);
|
---|
28 | * // => true
|
---|
29 | *
|
---|
30 | * _.isNumber('3');
|
---|
31 | * // => false
|
---|
32 | */
|
---|
33 | function isNumber(value) {
|
---|
34 | return typeof value == 'number' ||
|
---|
35 | (isObjectLike(value) && baseGetTag(value) == numberTag);
|
---|
36 | }
|
---|
37 |
|
---|
38 | module.exports = isNumber;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.