📜  忽略数组中的空字段 - Javascript代码示例

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

代码示例1
var colors=["red","blue",,null,undefined,,"green"];

//remove null and undefined elements from colors
var realColors = colors.filter(function (e) {return e != null;});
console.log(realColors);