Skip to content

Instantly share code, notes, and snippets.

@911992
Created December 26, 2020 18:05
Show Gist options
  • Save 911992/df6abd8a4644e34f06b07ebdb73e6fde to your computer and use it in GitHub Desktop.
Save 911992/df6abd8a4644e34f06b07ebdb73e6fde to your computer and use it in GitHub Desktop.
Javascript object equal check
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