[Webkit-unassigned] [Bug 14901] for in loop on an Array does not work

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Sep 17 12:44:27 PDT 2008


https://bugs.webkit.org/show_bug.cgi?id=14901





------- Comment #7 from wesc at antitribu.com  2008-09-17 12:44 PDT -------
I'm working with Chrome (beta) and having a similar issue with for/in and
arrays. Here is my test script:

var myarray = [5,3,8,"test","nowork"];
for (var elem in myarray) {
  document.write("<br>" + elem);
}

Here is my output:

0
1
2
3
4

It appears to be outputting the array keys instead of the array values. The
following code works perfectly, but for my solution, I can't count on
contiguous  array elements, so this solution requires a lot more logic than a
simple for/in loop.

for (var ii = 0; ii < myarray.length; ii++) {
  document.write("<br>" + myarray[ii]);
}


-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the webkit-unassigned mailing list