[Javascript] Lodash

jen·2021년 7월 6일
0

Javascript

목록 보기
1/1

.filter(collection, [predicate=.identity])

https://lodash.com/docs/4.17.15#filter


var users = [
  { 'user': 'barney', 'age': 36, 'active': true },
  { 'user': 'fred',   'age': 40, 'active': false }
];

// age 40 찾기
_.filter(users, {'age': 40})


_.filter(users, function(o) { return !o.active; });
// => objects for ['fred']
 
// The `_.matches` iteratee shorthand.
_.filter(users, { 'age': 36, 'active': true });
// => objects for ['barney']
 
// The `_.matchesProperty` iteratee shorthand.
_.filter(users, ['active', false]);
// => objects for ['fred']
 
// The `_.property` iteratee shorthand.
_.filter(users, 'active');
// => objects for ['barney']

0개의 댓글