var a = { a1: "a1", a2: "a2" }; var b = { b1: "b1", b2: "b2" }; for (var item in b) { a[item] = b[item]; } console.log(a)
var o1 = { a: 1 }; var o2 = { b: 2 }; var obj = Object.assign(o1, o2);
方法很多,就不一一举例了!!!
对象合并,对象和数组都分不清,学学js基础,别急于求成