var elem1, elem2;
// document.forms is an HTMLCollection
elem1 = document.forms[0];
elem2 = document.forms.item(0);
alert(elem1 === elem2); // shows: "true"
elem1 = document.forms["myForm"];
elem2 = document.forms.namedItem("myForm");
alert(elem1 === elem2); // shows: "true"
Src: https://developer.mozilla.org/en-US/docs/Web/API/HTMLCollection
In the above code variables elem1
and elem2
both hold same object, i.e. a DOM node
I would like to know, In the statement elem1 === elem2
what is actually being compared
so that it evaluates to a TRUE
expression. Is it nodeType
, nodeValue
or nodeName
?