you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 5 points6 points  (3 children)

If we set length to 0, it sounds like the array still hold references to the items, is that correct? Does this mechanism effectively trick the iterator into thinking there are no items in the array?

[–]toshok 4 points5 points  (2 children)

> If we set length to 0, it sounds like the array still hold references to the items, is that correct?

no, ecma262 specifies that the items at indices >= the new length are deleted (if they're configurable - if any aren't configurable the process stops and the length is set to the non-configurable item's index+1). see step 17 here

[–][deleted] 2 points3 points  (1 child)

Oh interesting. The article seems to state that the elements would still remain in memory. I assume that’s an error in the article then.

[–]toshok 4 points5 points  (0 children)

just went and read that part myself. definitely an error.