Visit Mozilla.org

Talk:Core JavaScript 1.5 Reference:Statements:for...in

From MDC

There is a for each (variable in list) statement in Gecko 1.8a2. It is meant for E4X compatibility but seems to be available for all types of lists. Maybe this should be documented? --Wladimir Palant 08:00, 21 Jul 2005 (PDT)

Contents

[edit] Breadcrumbs

As of this writing the breadcrumbs output on this article is wrong. I filed bug 326770 regarding the issue. --Callek 20:33, 10 February 2006 (PST)

[edit] sorted enumeration

ECMA 262 says nothing about the order of for .. in's enumerated attributes being lexicographically sorted/ordered, but all versions of JS appear to do this sorting. I've seen code that relies on it. Worth a documentation note?

[edit] note on use with arrays

Callek writes:

In my opinion, the Description covers the warning expressed in the added text.

It does, but using for...in with arrays, and expecting it to return purely numeric indexes, is a common newbie mistake, and in my opinion warranted the more verbose note. So I'm restoring the note removed in the 11 February 2006 revision. --Tmetro 10:40, 20 September 2006 (PDT)

[edit] mutating the array

It might be worth a note that mutating the array (using Array.splice in my case) would exhibit the same behaviour one would see with a manual for loop - some elements get skipped / repeated / etc. Not going to do that myself with the recent posts in m.d.mdc about accidentally changing meaning though! :) --Mook 01:10, 24 December 2006 (PST)

_Please_ make the change yourself. You can try getting a review from waldo or someone afterwards. If you don't make it, there's a high chance that no-one will. --Nickolay 07:35, 24 December 2006 (PST)
I just made some changes which should hopefully address the mutation aspect. Feel free to say something here if you see improvements to my wording; I'm sure there are several which could be made, but I was trying not to be overly verbose. (Regarding hesitancy to make changes, I echo Nickolay -- make the change and post a request for review to the newsgroup, please.  :-) ) --Waldo 19:46, 6 January 2007 (PST)