DEV Community


Discussion on: JavaScript Equality Checks

andreybarkov profile image
Andrey Barkov

Can it be used to compare two different objects with same properties?

ronakjethwa profile image
Ronak Jethwa Author • Edited

Yes. Two different Objects with same properties are still two different objects with different memory references, so that would still return false with

let user1 = {name: 'John', age:29};
let user2 = {name: 'John', age:29};,user2); // false

Although, this will be different.

let user1 = {name: 'John', age:29};
let user2 = user1,user2); // true