Вопрос

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.

Это было полезно?

Решение

You don't want to use where that "performs a deep comparison to the given property object" , but filter that uses a callback.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top