var arr = [, 16,20,10];

    2 answers 2

    In case JS is not yet version 1.6 and does not support filter() :

     var arr = [,16,,20,10], tmp = []; for( var i in arr) tmp.push( arr[i]); arr = tmp.slice(); 

    Feeddle

    See about “holes” in arrays (in English)

      arr.shift();

      • and if arr = [16,20,, 10,]; ?? - Kill Noise
      • Do you need to remove all keys that have no value? arr = arr.filter (function () {return true;}); stackoverflow.com/a/281393/815386 - zb '