DEV Community

Discussion on: JavaScript Array Methods - Filtering

 
jonrandy profile image
Jon Randy 🎖️ • Edited

Yep. Using an identity function like that with filter will remove anything 'falsy' from the array:

arr.filter(i => i)
Enter fullscreen mode Exit fullscreen mode

Also, you don't need the parentheses around the first str in your example

Thread Thread
 
orimdominic profile image
Orim Dominic Adah • Edited

Sure. I wrote this and copied it from a linted editor, that's why.
I also think it is more readable with the parentheses
Thanks