Merging objects within an array and keeping the highest value for identical properties
问题 I have this array and I would like to merge the objects within it. [null, null, {"1":1},{"2":1},{"3":1},{"2":2},{"5":1}] I thought about using something like this: var o1 = { a: 1, b: 1, c: 1 }; var o2 = { b: 2, c: 2 }; var o3 = { c: 3 }; var obj = Object.assign({}, o1, o2, o3); console.log(obj); // { a: 1, b: 2, c: 3 } However, the properties are overwritten by other objects that have the same properties later in the parameters order What I want is to keep the highest value available for the