Per Ström Per Ström - 7 months ago 39
Javascript Question

Filter out an array with null values, underscore

I have this array:

[null, {name:'John'}, null, {name:'Jane'}]

I want to remove the null values. Is there an easy way to do this with underscore?


Try using _.without(array, *values) it will remove all the values that you don't need. In your case *values == null