Answers for "javascript update multiple values of an object"

0

javascript update multiple values of an object

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)
Posted by: Guest on June-25-2020

Code answers related to "javascript update multiple values of an object"

Code answers related to "Javascript"

Browse Popular Code Answers by Language