- 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 - every method
Syntax
_.every(collection, [predicate=_.identity])
Checks if predicate returns truthy for all elements of collection. Iteration is stopped once predicate returns falsey. The predicate is invoked with three arguments: (value, index|key, collection).
Arguments
collection (Array|Object) − The collection to iterate over.
[predicate=_.identity] (Function) − The function invoked per iteration.
Output
(boolean) − Returns true if all elements pass the predicate check, else false.
Example
var _ = require('lodash'); var list = [ { 'user': 'Joe', 'age': 36, 'active': false }, { 'user': 'Jake', 'age': 40, 'active': false } ]; var result = _.every(list, ['active', false]); console.log(result);
Save the above program in tester.js. Run the following command to execute this program.
Command
\>node tester.js
Output
true
lodash_collection.htm
Advertisements