📜  两个对象结合在一起 javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:12.791000             🧑  作者: Mango

代码示例3
const a = { b: 1, c: 2 };
const d = { e: 1, f: 2 };

const ad = { ...a, ...d }; // { b: 1, c: 2, e: 1, f: 2 }


let objs = [{firstName: "Steven"}, {lastName: "Hancock"}, {score: 85}];

let obj = objs.reduce(function(acc, val) {
    return Object.assign(acc, val);
},{});