Lodash教程

Lodash size method

语法:

_.size(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.

参数:

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.

命令:

\>node tester.js

输出:

3
2
7
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4