Filter out an array with null values, underscore

If the array contains either nulls or objects then you could use compact:

var everythingButTheNulls = _.compact(list);

NB compact removes all falsy values so if the array could contain zeros, false etc then they would also be removed.

Could also use reject with the isNull predicate:

var everythingButTheNulls = _.reject(array, _.isNull);

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)