Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/qq_40639990/article/details/81264081
// will filter out those false values
const compact = arr => arr.filter(Boolean);
var arr = compact([0,null,'0',12,34,undefined,false,NaN])
console.log(arr)