You don't want to use where
that "performs a deep comparison to the given property object" , but filter
that uses a callback.
Using LoDash, how do I integrate a function into a _where method?
-
19-06-2023 - |
Question
I have an array of objects that each have a date property. For some of the objects, the "Date" property is blank. I want to remove those from my object so that my view doesn't end up with entries containing NaN for the date.
Here is what I have tried:
_.where(data, { 'Date': d.Date instanceof Date && isFinite(d) })
AND
_.where(data, function(d) {
return d.Date instanceof Date && isFinite(d.date);
});
Both return 0 results however.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow