size source npm

_.size(collection)

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

Arguments

  1. collection (Array|Object)

    The collection to inspect.

Returns (number)

Returns the collection size.

Example

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

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

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