比较两个对象后如何返回对象?
例如,我有:
const x = {name: "Hello", cats: [cat1: "Name1", cat2: "Name2"]};
const y = {name: "Hello2", cats: [cat1: "Name4"]};
我想对此进行比较,并返回具有不同结果的新对象。 像这样:
const result = x.toCompare(y);
result is: {name: "Hello2", cats: [cat1: "Name4", cat2: "Name2"]"}