I'm familiar with _.without
function
This will remove specific values from an array:
_.without([1, 2, 1, 3], 1, 2);
// → [3]
Is there a built-in / lodash function (or - how can I implement an efficient one) that remove not a specific value but a var with a specified field value/
_.without([ { number: 1}, {number: 2} ], 1)
// -> [ {number: 2} ]
I'm familiar with _.without
function
This will remove specific values from an array:
_.without([1, 2, 1, 3], 1, 2);
// → [3]
Is there a built-in / lodash function (or - how can I implement an efficient one) that remove not a specific value but a var with a specified field value/
_.without([ { number: 1}, {number: 2} ], 1)
// -> [ {number: 2} ]
Share
Improve this question
edited Nov 13, 2015 at 3:19
royhowie
11.2k14 gold badges53 silver badges67 bronze badges
asked Oct 26, 2015 at 22:01
ShikloshiShikloshi
3,8119 gold badges39 silver badges60 bronze badges
1 Answer
Reset to default 16You can use _.filter
:
_.filter([ { number: 1}, {number: 2} ], (o) => o.number != 1)
or, without the new arrow notation:
_.filter([ { number: 1}, {number: 2} ], function (o) { return o.number != 1 })