Node.js lodash where() filter object array attribute

Description

Node.js lodash where() filter object array attribute


var _ = require('lodash');
var objects = [{name: 'Ford', contentsOfPockets: ['guide', 'lint', 'booze']},
               {name: 'Arthur', contentsOfPockets: ['guide', 'last bag of tea']},
               {name: 'Marvin', contentsOfPockets: ['dispair', 'electrodes']},
               {name: 'Zaphod', contestsOfPockets: ['kill-o-zap', 'infinite perspective']}];

var results = _.where(objects, {contentsOfPockets: ['guide']});
console.log(results);/*w ww  .j a  v a 2 s . com*/



PreviousNext

Related