Created
May 13, 2015 14:01
-
-
Save lotsofcode/ee21af5bd02c54a02d1a to your computer and use it in GitHub Desktop.
remove empty elements from array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// js 1.6+ | |
arr = arr.filter(function(n){ return n != undefined }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment