More complicated description of Array length #53

Closed
azproduction opened this Issue Mar 21, 2011 · 0 comments

Comments

Projects
None yet
2 participants
var foo = [1, 2, 3, 4, 5, 6];
foo.hasOwnProperty(5); // true - 6 exists
foo.length = 3;
foo; // [1, 2, 3]
foo.hasOwnProperty(5); // false - we have reduced array

foo.length = 6;
foo; // [1, 2, 3]
foo.hasOwnProperty(5); // false
foo.join(); // "1,2,3,,," join lies, because it uses length property
foo[5] = void 0; // set undefined
foo.hasOwnProperty(5); // true, because we have created undefined var manually
foo.join(); // "1,2,3,,," same

timruffles closed this Apr 30, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment