UNPKG

667 BJavaScriptView Raw
1import toInteger from './toInteger.js';
2
3/**
4 * Checks if `value` is an integer.
5 *
6 * **Note:** This method is based on
7 * [`Number.isInteger`](https://mdn.io/Number/isInteger).
8 *
9 * @static
10 * @memberOf _
11 * @since 4.0.0
12 * @category Lang
13 * @param {*} value The value to check.
14 * @returns {boolean} Returns `true` if `value` is an integer, else `false`.
15 * @example
16 *
17 * _.isInteger(3);
18 * // => true
19 *
20 * _.isInteger(Number.MIN_VALUE);
21 * // => false
22 *
23 * _.isInteger(Infinity);
24 * // => false
25 *
26 * _.isInteger('3');
27 * // => false
28 */
29function isInteger(value) {
30 return typeof value == 'number' && value == toInteger(value);
31}
32
33export default isInteger;