Skip to content

Instantly share code, notes, and snippets.

@jamiel
Created July 18, 2012 05:26
Show Gist options
  • Save jamiel/3134380 to your computer and use it in GitHub Desktop.
Save jamiel/3134380 to your computer and use it in GitHub Desktop.
Yet another javascript gotcha
Auto-filling Array Keys
=======================
var foo = new Array();
foo[500] = 'bar';
console.log(foo.length); // 501
// And it gets worse:
var foo = new Array();
foo["500"] = 'bar';
console.log(foo.length); // 501
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment