Per Ström Per Ström - 3 months ago 11x
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