mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 14:37:49 +00:00
32 lines
788 B
JavaScript
32 lines
788 B
JavaScript
import isFunction from './isFunction.js'
|
|
import isLength from './isLength.js'
|
|
|
|
/**
|
|
* Checks if `value` is array-like. A value is considered array-like if it's
|
|
* not a function and has a `value.length` that's an integer greater than or
|
|
* equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
|
|
*
|
|
* @since 4.0.0
|
|
* @category Lang
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
|
|
* @example
|
|
*
|
|
* isArrayLike([1, 2, 3])
|
|
* // => true
|
|
*
|
|
* isArrayLike(document.body.children)
|
|
* // => true
|
|
*
|
|
* isArrayLike('abc')
|
|
* // => true
|
|
*
|
|
* isArrayLike(Function)
|
|
* // => false
|
|
*/
|
|
function isArrayLike(value) {
|
|
return value != null && isLength(value.length) && !isFunction(value)
|
|
}
|
|
|
|
export default isArrayLike
|