Eg.:
let userOne = {
name: "Test",
surname: "Test"
}
let userTwo = {
...userOne
}
console.log(userOne === userTwo); // false
But, eg.:
console.log(userOne.name === userTwo.name); // true
So userOne and userTwo are two refeneces of the same object but console.log(userOne === userTwo);
returns fasle.
Why is it?
Modification: Ok. In the previous example there are two object. But what about this:
let userOne = {
name: "Test",
surname: "Test surname",
sizes: {
width: 200,
height: 200,
}
}
let userTwo = {
...userOne
}
userTwo.sizes.width = 50;
alert(userOne.sizes.width); // 50
So userOne and userTwo are the references the same object.
But: alert(userOne == userTwo);// false
So the the two references does not point to the same object?