(Greed) Properties of object assigned to this are read only?


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.


Upon further experimentation, it seems like this only applies if the variable on this is defined inside my initialize function, which is only run on the first frame. If I set values on this after the first frame, they seem to work fine. o.O


I’ll see what I can do about this. It seems like the API protection has gotten a bit overzealous there. Tracking the issue over here–at least, if it’s not the same issue, it’s related.