Is there a way to check if two DOM elements are equal?

In modern browsers there are two methods for comparing nodes.

var a = document.createElement('div');
var b = document.createElement('div');
b.isEqualNode(a); // true

but

b.isSameNode(a); //false

And as for IE, it's DOM elements have non-stanard attribute, uniqueID. But I can't imagine it can be useful in this case, since yes, you actually can compare two pointers.


If you want to compare two element pointers for being the same element, just use the comparison operator. This can be easily proven because

document.body === document.body

For example, if I somehow had references to two elements I didn't know:

if (element1 === element2) ...