Laurens Groeneveld
March 27, 2026

.filter(Boolean)

In JavaScript, using .filter(Boolean) on an array of strings will filter out all empty string values. Noticed this in a code review today. I'd probably prefer .filter(v => v !== "") for clarity, but it's kinda neat.

© Laurens Groeneveld - Content and website licensed under CC BY-SA 4.0