I have a function of the prototype of an object called getComponent which returns this.components[name]
function Foo()
{
this.components = {"Scripts": [...], "Sprites": [...], "States": {...}, etc };
}
Foo.prototype.getComponent = function(name)
{
return this.components[name];
}
Then I have some code that gets a component and sets it to something else...
var foo = new Foo();
foo.getComponent("Sprites") = [];
This obviously raises the Uncaught ReferenceError: Invalid left-hand side in assignment.
Is there anyway to set the value of the returned value?
I don't want to access the objects variables directly: foo.components.Sprites = [].
Thanks in advance,
David
settermethod just like thegetComponentmethod to update the value