Skip to content

size

js
_.size(collection)

通过返回类似数组的值的长度或对象的可枚举字符串键属性的数量来获取 collection 的大小。

¥Gets the size of collection by returning its length for array-like values or the number of own enumerable string keyed properties for objects.

新增于

¥Since

0.1.0

参数

¥Arguments

  1. collection (数组|对象|字符串):要检查的集合。

    ¥collection (Array|Object|string): The collection to inspect.

返回

¥Returns

(数值):返回集合大小。

¥(number): Returns the collection size.

示例

¥Example

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

_.size({ 'a': 1, 'b': 2 });
// => 2

_.size('pebbles');
// => 7

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