how to merge objects js code example
Example 1: merge two objects javascript
const object1 = {
name: 'Flavio'
}
const object2 = {
age: 35
}
const object3 = {...object1, ...object2 }
Example 2: merge two objects javascript
Object.assign(target, sourceObj1, sourceObj2, ...);
Example 3: merge objects js
Object.assign(obj1, obj2);
const allRules = Object.assign({}, obj1, obj2, obj3, etc);
Example 4: javascript combine objects
const obj1 = {'a': 1, 'b': 2};
const obj2 = {'c': 3};
const obj3 = {'d': 4};
const objCombined = {...obj1, ...obj2, ...obj3};