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
  • 3,552
  • 5
  • 24
  • 47

1 Answers1

-4

Do you try it?

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