Skip to content

Instantly share code, notes, and snippets.

@jamiel jamiel/gist:3134380
Created Jul 18, 2012

Embed
What would you like to do?
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
You can’t perform that action at this time.