Skip to content

Instantly share code, notes, and snippets.

@lotsofcode
Created May 13, 2015 14:01

Revisions

  1. lotsofcode created this gist May 13, 2015.
    10 changes: 10 additions & 0 deletions removeEmpty
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    // pre 1.6
    function cleanArray(actual){
    var newArray = new Array();
    for(var i = 0; i<actual.length; i++){
    if (actual[i]){
    newArray.push(actual[i]);
    }
    }
    return newArray;
    }
    2 changes: 2 additions & 0 deletions removeEmpty.1.6
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    // js 1.6+
    arr = arr.filter(function(n){ return n != undefined });