I want to understand how objects work in JS.
const obj = { inner: { a: 'Hello' } };
const clone = { ...obj };
// obj === clone -> false
// !!! BUT !!!
// obj.inner === clone.inner -> true
clone.inner = { a: 'world' };
// obj === { inner: { a: 'Hello' } }
// clone === { inner: { a: 'World' } }
Is there a documentation on this behaviour? Can I rely on inner objects references equality while creating new object via spread operator?