Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

remove falsy values from array javascript

let mixedArr = [0, “blue”, “”, NaN, 9, true, undefined, “white”, false];
let trueArr = mixedArr.filter(Boolean);
console.log(trueArr); // returns [“blue”, 9, true, “white”]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #remove #falsy #values #array #javascript
ADD COMMENT
Topic
Name
9+3 =