var a = {
  1: {
    687: {
      name:'test1'
    }
  }
}
var b = {
  1: {
    689: {
      name:'test2'
    }
  }
}
var c = {
  ...a,
  ...b
}
console.log(c)I was expecting the result to be :
{
  1: {
    687: {
      name:'test1'
    },
    689: {
      name:'test2'
    }
  }
}But, it is :
{
  1: {
    689: {
      name:'test2'
    }
  }
}Am I using spread operator wrong? What is the most efficient way to merge two objects? I made a function which iterates through each key in the objects, it works but I think it's not the write way.
Object.assign({},a,b) also returns the same (first result, which I don't want).
I went through the question How can I merge properties of two JavaScript objects dynamically?
But It doesn't answer my question. this answer (https://stackoverflow.com/a/171256/1352853) is also not what I want.
Thanks in advance.
 
    