google-code-export / game-golem

Automatically exported from code.google.com/p/game-golem
0 stars 0 forks source link

For (n in list) is broken #302

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Use a loop for (x in list)
2. Watch strange and inexplicable values for x come back like "unique" or 
"remove"
3. Wonder why?

What is the expected output? What do you see instead?
If list = ['a','b','c'], then for (x in list) should return 0, 1, 2, not 0, 1, 
2, "unique", "remove".

Original issue reported on code.google.com by 0Artifi...@gmail.com on 18 Apr 2011 at 11:22

GoogleCodeExporter commented 9 years ago
Arrays were extended via prototype some weeks back to support a few new 
methods, so this is now expected behavior. See Rycochet's note in the r1017 
patch notes for clarification.

"IMPORTANT - Array now has prototype functions, make sure you use 
for(i=0;i<arr.length;i++) and not for(i in arr) or it will error out (an 
alternative is using if(arr.hasOwnProperty(i))."

Original comment by lur...@hotmail.com on 18 Apr 2011 at 2:54

GoogleCodeExporter commented 9 years ago

Original comment by 0Artifi...@gmail.com on 29 Apr 2011 at 2:34