shallow comparison
When comparing scalar values (numbers, strings) it compares their values.
When comparing objects, it does not compare their attributes
- only their references are compared
Shallow compare is an efficient way to detect changes
// Example:
user = {
name: "John",
surname: "Doe"
}
// User1
const user = this.state.user;
user.name = "Jane";
console.log(user === this.state.user); // true:The references are the same.
// User2
const user = clone(this.state.user);
console.log(user === this.state.user);
// false:Cloning: you create a new copy with a different reference