0

I want to merge 2 objects where there's a similar prop on both and I want to have all props together:

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"}}

Do I need to use the spread operator in some way?

Moshe
  • 4,635
  • 6
  • 32
  • 57

1 Answers1

-4

Do you try it?

var hege = ["Cecilie", "Lone"];
var stale = ["Emil", "Tobias", "Linus"];
var children = hege.concat(stale);
novac
  • 116
  • 8