I have an object like this
initialize : {
method : function() {
this.__. //--> do another thing
... //--> so many
this.__.params. //--> do another thing
... //--> so many
}
}
and the method of this object call by another function. As you can see, we have many lines that refer to this.__
and this.__.
params, and for preventing this, I declare local variables T
and P
like below
initialize : {
method : function() {
var T = this.__, P = T.params;
T. //--> do another thing
... //--> so many
P. //--> do another thing
... //--> so many
}
}
as I mentioned before the method calls by another function called caller
.
Is it possible to not declare locale variables in the method function and instead define them in scope of the caller
function and pass it to the method ?
method
as if it were its own method (and thereforethis
references the other object). I'm assuming that since you're trying to simplify this bit of code, it's a user-extendable part of some library. I don't really see any problem with it as-is (except for the__
name, which is a bit odd). I guess I'd need more context to know why you want to simplify it. You certainly shouldn't have the caller define the variables for you (which is impossible anyway), but I don't see why you can't just use normal parameters? – Dave Oct 13 '13 at 11:58this
andthis.__
is, maybe we can provide another approach. – Joseph the Dreamer Oct 13 '13 at 12:07