Abaikan bidang kosong dalam array

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);
Grepper