I have got an object of defaults, then some values which will over-ride the defaults. However when i use Object.assign
to create a new object, and update this, the defaults also get changed.
let defaults = { test: 'hello world' };
let values = { test: 'beep' };
let merged = Object.assign(defaults, values);
merged.test = 'updated'
// defaults: { test: 'updated' }
Defaults should remain the same and only merged
should get updated. I was under the impression that Object.assign
copies the object, not references it.