Created
December 26, 2020 18:05
-
-
Save 911992/df6abd8a4644e34f06b07ebdb73e6fde to your computer and use it in GitHub Desktop.
Javascript object equal check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a={a:0,b:0}; | |
var b={a:0,b:0}; | |
var c={}; | |
var d= a; | |
Object.assign(c,a); | |
console.log("a == b "+(a==b)); // false as b has different ptr than a | |
console.log("a == c "+(a==c)); // false as c has its ptr too | |
console.log("a == d "+(a==d)); // trueas the d is athe ptr referencing to the a | |
console.log("b == c "+(c==b)); // false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment