Skip to content

Instantly share code, notes, and snippets.

@cssimsek
Created May 16, 2014 10:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cssimsek/210143570876f220eb8f to your computer and use it in GitHub Desktop.
Save cssimsek/210143570876f220eb8f to your computer and use it in GitHub Desktop.
Empty an array by popping the elements
var myArray = [0, 1, 2, 3, 4, 5];
console.log(myArray);
var originalLength = myArray.length;
for(var i = originalLength; i > 0; i--) {
myArray.pop();
console.log(myArray);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment