I have a type that looks a little something like this:
var x = function(){
this.y = function(){
}
this.z = function(){
...
this.A = function(){
CALLING POINT
}
}
}
From calling point, I'm attempting to call function this.y. I don't need to pass any parameters, but when I set some stuff from this.A, I need to call this.y.
Is this possible? I'm OK with passing extra parameters to functions to make it possible.
You cannot because
this.y()
is not within the scope thatthis.A()
is in. You can if you setthis.y()
to a global functiony
:Version with
bind
, basically this adds a new methoda
to the object.Working example with saved inner
this
.Yes, you can assign
this
reference to another variable and then call functiony
on it