Array class now has methods like
filter, which are very useful.
If you need to support older browsers, which you probably do, this filtering method can be also found in MooTools (
Array#filter), jQuery (
$.grep) and other JS frameworks.
A quick tip to remove all falsy (
NaN or an empty string) items out of an array:
Boolean constructor is also a function, it returns either
true for ‘truthy’ argument or
false for ‘falsy’ argument.
1 2 3 4 5
is actually the same as writing: