Russ
0
Q:

lodash find object in array

var users = [
  {id:1,name:'ted'},
  {id:1,name:'ted'},
  {id:1,name:'bob'},
  {id:3,name:'sara'}
];
var uniqueUsersByID = _.uniqBy(users,'id'); //removed if had duplicate id
var uniqueUsers = _.uniqWith(users, _.isEqual);//removed complete duplicates
-1
var users = [
  { 'user': 'barney',  'age': 36, 'active': true },
  { 'user': 'fred',    'age': 40, 'active': false },
  { 'user': 'pebbles', 'age': 1,  'active': true }
];
 
_.find(users, function(o) { return o.age < 40; });
// => object for 'barney'
0
_.flatMap(names, (nameObj) => _.map(nameObj, (objVal) => { return { name: objVal }; }));
3
_.each(markets, (obj, key) => {   obj.symbol = key})console.log(markets)//=> {       'BTC/USD': { buys: 0, sells: 3, symbol: 'BTC/USD' },       'DASH/BTC': { buys: 3, sells: 1, symbol: 'DASH/BTC' },       'ETH/BTC': { buys: 3, sells: 2, symbol: 'ETH/BTC' }    }
0
var object = { 'a': [{ 'b': { 'c': 3 } }] }; _.get(object, 'a[0].b.c');// => 3 _.get(object, ['a', '0', 'b', 'c']);// => 3 _.get(object, 'a.b.c', 'default');// => 'default'
0

New to Communities?

Join the community