Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

item() Method is a String Value - IE7

0 views
Skip to first unread message

dhtml

unread,
Jun 19, 2008, 6:29:30 PM6/19/08
to
In IE7, this:-

alert(document.body.childNodes.item === "[object]");

is true.

Why is childNodes.item returning "[object]" ?

Garrett

Evertjan.

unread,
Jun 19, 2008, 6:32:54 PM6/19/08
to

Because it is a collection:

.item(0), .item(1), I think.


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

dhtml

unread,
Jun 19, 2008, 6:49:26 PM6/19/08
to
On Jun 19, 3:32 pm, "Evertjan." <exjxw.hannivo...@interxnl.net> wrote:
> dhtml wrote on 20 jun 2008 in microsoft.public.scripting.jscript:
>
> > In IE7, this:-
>
> > alert(document.body.childNodes.item === "[object]");
>
> > is true.
>
> > Why is childNodes.item returning "[object]" ?
>
> Because it is a collection:
>

Item should be a Host object, not a string value. In fact, item() is
callable, so it could reasonably be considered a function
(implementation dependent). Method item() also seems to implement
[[call]] in IE:-
:-
javascript:alert(Function.prototype.call.call(document.body.childNodes,
document.body.childNodes.item, 0))

(But that's beside the point.)

My original example:-
alert(document.body.childNodes.item === "[object]");

Uses strict equality, ===

With strict equality, when comparing an object and a string value, the
result should be false (as is true with strict comparison of any two
obects of different types).

Is - item - an object or a string value?

It appears [[Get]] would find - item - on - childNodes - directly:-
javascript:alert(Object.prototype.hasOwnProperty.call(document.body.childNodes,
"item"))

I'm at a loss as to understand why [[Get]] returns "[object]" for the
- item - property.

Garrett

0 new messages