const animals= {};
let dog = {emoji: 'a'}
let cat = {emoji: 'b'}
animals[dog] = {...dog, name: "Mara"}
animals[cat] = {...cat,name: "Sara"}
console.log(animals[dog]) //{emoji: "b",name: "Sara"}
2023-11-25 12:02:22
const animals= {};
let dog = {emoji: 'a'}
let cat = {emoji: 'b'}
animals[dog] = {...dog, name: "Mara"}
animals[cat] = {...cat,name: "Sara"}
console.log(animals[dog]) //{emoji: "b",name: "Sara"}
animals["object object"]
现在等于 {emoji: “a”,name: “Mara”}。animals[cat]
实际上意味着我们在用新的cat的属性覆盖 animals["
object object "
] 的值。