Skip to content

Instantly share code, notes, and snippets.

@omgmog
Created April 27, 2016 12:38
Show Gist options
  • Save omgmog/8b3e4144b65f6d310e197a47e2da5e73 to your computer and use it in GitHub Desktop.
Save omgmog/8b3e4144b65f6d310e197a47e2da5e73 to your computer and use it in GitHub Desktop.
var arr = [];
arr[100] = 'Foo';
// Outputs lots of 'undefined' and then the value for arr[100]
for (var i=0;i<arr.length;i++) {
console.log(arr[i]);
}
// Outputs just the indexes with a value defined
for (var item in arr) {
console.log(item);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment