📜  以非常简单的方式从数组中过滤出虚假值! - Javascript代码示例

📅  最后修改于: 2022-03-11 15:02:23.495000             🧑  作者: Mango

代码示例1
var arr = [ 0, 1, '', undefined, false, 2, undefined, null, , 3, NaN ];
 
var filtered = arr.filter(Boolean);
console.log(filtered);
 
/*
    Output: [ 1, 2, 3 ]
*/