Answers for "filter the falsy values out of an array in a very simple way!"

0

filter the falsy values out of an array in a very simple way!

var arr = [ 0, 1, '', undefined, false, 2, undefined, null, , 3, NaN ];
 
var filtered = arr.filter(Boolean);
console.log(filtered);
 
/*
    Output: [ 1, 2, 3 ]
*/
Posted by: Guest on August-12-2021

Code answers related to "filter the falsy values out of an array in a very simple way!"

Code answers related to "Javascript"

Browse Popular Code Answers by Language