How can you check if two or more objects/vars have the same reference?
Use the is operator to check if two variables reference the same object. Use the is operator to check two variables for identity and == to check for two variables for equality.
a doublelinked list may be a concrete example where you have multiple references to the same object.
You use ==
or ===
:
var thesame = obj1===obj2;
From the MDN :
If both operands are objects, then JavaScript compares internal references which are equal when operands refer to the same object in memory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With