javascript update multiple values of an object

Solutions on MaxInterview for javascript update multiple values of an object by the best coders in the world

showing results for - "javascript update multiple values of an object"
Martina
09 Jul 2016
1var myObject = {
2    label: 'foo',
3    name: 'bar',
4    id: 12
5};
6
7myObject = {...myObject, label: 'baz', name: 'qux'};
8console.log(myObject);
9
10// Or, if your update is contained in its own object:
11
12var myUpdate = {
13    label: 'something',
14    name: 'else'
15}
16
17myObject = {...myObject, ...myUpdate}
18console.log(myObject)