Node.js lodash explicit chaining

Description

Node.js lodash explicit chaining


var _ = require('lodash');

var people = [// w ww.j av a2s  .co  m
  { id: 1, name: "Jim", age: 20, gender: 'm', enabled: true },
  { id: 1, name: "Jim", age: 20, gender: 'm', enabled: false },  
  { id: 2, name: "Bob", age: 34, gender: 'm', enabled: true },
  { id: 3, name: "Steve", age: 30, gender: 'm', enabled: true },
  { id: 4, name: "Nancy", age: 42, gender: 'f', enabled: true },
  { id: 5, name: "Frank", age: 30, gender: 'm', enabled: true },
  { id: 6, name: "Larry", age: 68, gender: 'm', enabled: true }
];


var r = _.chain(people)
  .filter({gender: 'm'})
  .first()
  .value();
  

console.log(r);



PreviousNext

Related