https://bugzilla.wikimedia.org/show_bug.cgi?id=28931
--- Comment #4 from Bawolff <[email protected]> 2011-05-12 19:16:09 UTC --- (In reply to comment #3) > > @Bawolff: > Yes, this recommendation would cover most cases since it skips prototype > members of the object (e.g. added by libraries). But the following code would > still not work as expected: > > var a, index; > a = ['a', 'b', 'c']; > a.name = 'MyArray'; > for (index in a) // <= WRONG > { > if (a.hasOwnProperty(index)) { > alert(index + ' = ' + a[index]); > } > } Well I suppose that varies with your definition of "expected". It would behave how I expect it would, as well as exactly the same as how such constructs behave in other languages like PHP. A basic for loop is probably always better when you just want to go through the numeric keys in order. -- Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug. _______________________________________________ Wikibugs-l mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/wikibugs-l
