When merging two objects in javascript, you can shallow merge them, or deep merge them. You can do it strictly through JavaScript or you can use a library such as Lodash
and deepmerge
to achieve your desired outcome. These videos show how to do both, and talk about the pros and cons of each approach.