Consider the following function:
function bouncer(arr) {
return arr.filter(Boolean);
}
The filter method is gonna iterate through the array and apply the function inside it (i.e. Boolean
) to each element of the array and if the element evaluates to true it will include it in the array, my question is, why is Boolean
doesn’t have an argument like Boolean(x)
?
for example:
function bouncer(arr) {
return arr.filter( x => Boolean(x));
}