DEV Community

Discussion on: How to filter() your school lunch because nobody wants meatloaf

Collapse
 
mellen profile image
Matt Ellen

A way I have used filter is to get rid of undefined array elements. It has the risk of filtering all falsey values, but if you know those values are not going to exist or should also be filtered, then array.filter(x => x) is a short bit of code to get rid of the undefined elements in your array.

Collapse
 
brettthurs10 profile image
Brett Thurston

Thanks Matt! Perfectly condensed.