我想合并2个对象,两者都有类似的道具,我想把所有道具放在一起:
let obj1 = {'foo': 'bar', 'far': {'tst': 1}}
let obj2 = {'far': {'other': 'token'}}
Object.assign({},obj1, obj2);
// Outputs: {"foo":"bar","far":{"other":"token"}}
// Desired output: {"foo":"bar","far":{'tst': 1, "other":"token"}}
我是否需要以某种方式使用点差运算符?
答案 0 :(得分:-4)
你试试吗?
var hege = ["Cecilie", "Lone"];
var stale = ["Emil", "Tobias", "Linus"];
var children = hege.concat(stale);