'Javascript: overwriting object inside object

Why is 'a' doesn't change even after changing the value of 'name' which is passed as a key in an object?

How can we actually compare the whole object inside the object?

const a = {
  name: "Laptop",
  age: 2,
  hasA: true,
}
let name = {
  mobile: true,
  number: 3
};
a[name] = true;
console.log(a[name]); // Output: true
name = {};
console.log(a[name]); // Output: true
console.log(JSON.stringify(a)); // {"name":"Laptop","age":2,"hasA":true,"[object Object]":true}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source