Should Javascript's "for in" construct iterate the length property?

Posted by Eric on Stack Overflow See other posts from Stack Overflow or by Eric
Published on 2010-03-24T18:38:03Z Indexed on 2010/03/24 18:43 UTC
Read the original article Hit count: 169

Filed under:
|
|
|

I'm making a bookmarklet, but I've encountered some wierd behaviour in IE8. The code causing the problem is this:

var els = document.getElementById("my_id").getElementsByTagName("*");
for(var i in els)
{
    alert(i+","+els[i])
}

The first thing that is alerted is "length, n". This isn't the case in chrome: just in IE8.

Interestingly, it seems to behave differently depending on whether the code goes in the console/address bar or the page itself.

Is this standard behaviour?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about ie8