Lodash size method
语法:
Gets the size of collection by returning its length for array-like values or the number of own enumerable string keyed properties for objects.
参数:
collection (Array|Object|string) − The collection to inspect.
输出:
(number) − Returns the collection size.
例子:
var _ = require('lodash');
var result = _.size([1, 2, 3]);
console.log(result);
result = _.size({ 'a': 1, 'b': 2 });
console.log(result);
result = _.size('pebbles');
console.log(result);
Save the above program in
tester.js. Run the following command to execute this program.
命令:
输出: