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

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Aug 8 07:24:49 PDT 2007


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


mitz at webkit.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mitz at webkit.org




------- Comment #5 from mitz at webkit.org  2007-08-08 07:24 PDT -------
(In reply to comment #4)
> var children = document.getElementsByTagName('SELECT');
> alert(children.length);
> for (var c in children) {
>    alert('loop '+c);
> }

The result of getElementsByName is not an array, it is a NodeList. for-in
enumerates properties of the NodeList object. To enumerate the nodes in the
NodeList you can do something like
for (var i = 0; i < children.length; i++)
    alert('loop' + children[i]);


-- 
Configure bugmail: http://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