This feels like a bug, but I’m admittedly new to JavaScript. I want to use something that is roughly like the following code:
if(this.initialized === undefined) {
this.initialized = true;
this.test = { blah : 5 };
this.updateTest = function(newValue) {
this.test.blah = newValue;
};
}
this.updateTest(this.test.blah + 5);
On this.test.blah = newValue I get the error:
“Cannot assign to read only property ‘blah’ of #<Object>”
Is there something I am missing here? Is it normal for objects that are assigned to objects to have read only properties in JavaScript and I haven’t noticed before, or is this an artifact of the CodeCombat framework?
edit: Also, I have no idea how to format the code. I surrounded it in tags, but the forum thinks it is smarter than I am.