I have an object with some keys, and I want to only keep some of the keys with their value?
I tried with filter:
filter
Lodash has a _.pickBy function which does exactly what you're looking for.
var thing = { "a": 123, "b": 456, "abc": 6789 }; var result = _.pickBy(thing, function(value, key) { return _.startsWith(key, "a"); }); console.log(result.abc) // 6789 console.log(result.b) // undefined