for in works wrong #2415

Closed
vitasimek opened this Issue Aug 27, 2012 · 1 comment

Comments

Projects
None yet
2 participants

Hi, I just tried some example for javascript's for in statement.
I tried in in jsfiddle.net where the mootool has been preselected.
I don't know anything about mootools, but if you take a look at the example and run it, you will see, that all items in the array are shown perfectly, but after all items in the array, some other stuff is shown. It looks like that are some mysterious items in that array. If I select another framework in fiddle (jQuery) the array is traversed correctly.

http://jsfiddle.net/WM5Xa/

Owner

arian commented Aug 27, 2012

Use ["Chris", "Kate", "Steve"].each(function(item, key){ ... }) or for (var i = 0; i < array.length; i++){ ... } loops. Not for-in loops for arrays.

arian closed this Aug 27, 2012

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