Why does this object update affect both variables?

Consider this snippet.

const a = { theme: 'dark' };
const b = a;
b.theme = 'light';
console.log(a.theme);

Why does this happen, and what is a simple way to avoid it.

BobaMilk

b = a copies the reference, not the object, so both names point at the same thing.

BayMax