let var1, var2;
// Obtaining elements from the HTMLCollection
var1 = document.forms[0];
var2 = document.forms.item(0);
alert(var1 === var2); // Output: "true"
var1 = document.forms["myForm"];
var2 = document.forms.namedItem("myForm");
alert(var1 === var2); // Output: "true"
Source: https://developer.mozilla.org/en-US/docs/Web/API/HTMLCollection
In the provided code snippet, variables var1
and var2
both refer to the same object, specifically a DOM node
I am curious about what exactly is compared in the statement var1 === var2
to result in a TRUE
value. Is it the nodeType
, nodeValue
, or nodeName
?