combine

combine

Merges object properties into a new combined object. When two objects have the same property, the value of the object that comes earlier in the array is used.

Parameters:
Name Type Argument Default Description
objects Array Array of objects that get merged together.
deep Boolean <optional>
true Perform a recursive merge.
allowDuplicates Boolean <optional>
true An error gets thrown if allowDuplicates is false and two objects contain the same property.
Throws:
DeveloperError : Duplicate member.
Returns:
Object combined object
Example
var object1 = {
    one : 1,
    deep : {
        value1 : 10
    }
}
var object2 = {
    two : 2
}
var object3 = {
    deep : {
        value1 : 5,
        value2 : 11
    }
}
var final = combine([object1,object2, object3], true, true);

// final === {
//     one : 1,
//     two : 2,
//     deep : {
//         value1 : 10,
//         value2 : 11
//     }
// }
Source: