- Lodash Tutorial
- Lodash - Home
- Lodash - Overview
- Lodash - Environment Setup
- Lodash - Array
- Lodash - Collection
- Lodash - Date
- Lodash - Function
- Lodash - Lang
- Lodash - Math
- Lodash - Number
- Lodash - Object
- Lodash - Seq
- Lodash - String
- Lodash - Util
- Lodash - Properties
- Lodash - Methods
- Lodash Useful Resources
- Lodash - Quick Guide
- Lodash - Useful Resources
- Lodash - Discussion
Lodash - size method
Syntax
_.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.
Arguments
collection (Array|Object|string) − The collection to inspect.
Output
(number) − Returns the collection size.
Example
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.
Command
\>node tester.js
Output
3 2 7
lodash_collection.htm
Advertisements