I'm having an issue with a JS object where a property value is being rewritten unexpectedly.
In the below example, after I set css_on['color'] = 'red';, outputting css_on to the console shows the correct value. However, after css_off['color'] = 'blue';, for some reason css_on.color is now also blue.
Can someone please tell me why this is happening? And how to stop it! Thanks.
var css = {
'line-height': this.options.height+'px',
'width': this.options.label_width+'px'
}
var css_on = css
var css_off = css;
css_on['color'] = 'red';
console.log(css_on);
css_off['color'] = 'blue';
console.log(css_on);