1const object1 = {
2 name: 'Flavio'
3}
4
5const object2 = {
6 age: 35
7}
8const object3 = {...object1, ...object2 } //{name: "Flavio", age: 35}
9
1var person={"name":"Billy","age":34};
2var clothing={"shoes":"nike","shirt":"long sleeve"};
3
4var personWithClothes= Object.assign(person, clothing);//merge the two object
5
1const a = { b: 1, c: 2 };
2const d = { e: 1, f: 2 };
3
4const ad = { ...a, ...d }; // { b: 1, c: 2, e: 1, f: 2 }
1/* For the case in question, you would do: */
2Object.assign(obj1, obj2);
3
4/** There's no limit to the number of objects you can merge.
5 * All objects get merged into the first object.
6 * Only the object in the first argument is mutated and returned.
7 * Later properties overwrite earlier properties with the same name. */
8const allRules = Object.assign({}, obj1, obj2, obj3, etc);
1const obj1 = {'a': 1, 'b': 2};
2const obj2 = {'c': 3};
3const obj3 = {'d': 4};
4
5const objCombined = {...obj1, ...obj2, ...obj3};