📌  相关文章
📜  javascript 更新对象的多个值 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:18.688000             🧑  作者: Mango

代码示例1
var myObject = {
    label: 'foo',
    name: 'bar',
    id: 12
};

myObject = {...myObject, label: 'baz', name: 'qux'};
console.log(myObject);

// Or, if your update is contained in its own object:

var myUpdate = {
    label: 'something',
    name: 'else'
}

myObject = {...myObject, ...myUpdate}
console.log(myObject)