Skip to content

isArrayLike

js
_.isArrayLike(value)

检查 value 是否类似数组。如果值不是函数并且 value.length 是大于或等于 0 且小于或等于 Number.MAX_SAFE_INTEGER 的整数,则该值被视为类似数组。

¥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

参数

¥Arguments

  1. value (*):要检查的值。

    ¥value ()*: The value to check.

返回

¥Returns

(布尔):如果 value 是数组类型,则返回 true,否则返回 false

¥(boolean): Returns true if value is array-like, else false.

示例

¥Example

js
_.isArrayLike([1, 2, 3]);
// => true

_.isArrayLike(document.body.children);
// => true

_.isArrayLike('abc');
// => true

_.isArrayLike(_.noop);
// => false

Lodash v4.17 中文网 - 粤ICP备13048890号