Array iteration pitfall

by Mohan 2012-09-20 22:59:07



Array iteration pitfall
var foo = [3,4,5];

for ( var i in foo ) {

if ( i == 1 ) {

foo.unshift(6);
}
Print('item: '+foo[i])
}
Print( 'array: '+foo.toSource() )
output:
item: 3
item: 3
item: 4
array: [6, 3, 4, 5]



770
like
0
dislike
0
mail
flag

You must LOGIN to add comments