lodash filter objects code example
Example 1: lodash filter object keys
var user = {
"first_name":"taylor",
"last_name":"hawkes",
"full_name": "taylor hawkes"
};
var userCleaned = _.pickBy(user, function(value, key) {
return (key === "first_name" || key === "last_name");
});
Example 2: Lodash filter
var users = [
{ 'user': 'barney', 'age': 36, 'active': true },
{ 'user': 'fred', 'age': 40, 'active': false }
];
_.filter(users, function(o) { return !o.active; });
_.filter(users, { 'age': 36, 'active': true });
_.filter(users, ['active', false]);
_.filter(users, 'active');
Example 3: lodash map
const _quote_filter = _.map(quote_state, (val, key) => { if (val) { return key }})console.log(_quote_filter)
Example 4: lodash map
_.each(markets, (obj, key) => { obj.symbol = key})console.log(markets)