Two options:
1) Accept getDatathe context parameter (usually called contextor thisArg) and use callback.apply(context, ...)or callback.call(context, ...)to call it. So:
function getData(callback, context) {
callback.call(context, arg1, arg2);
callback.apply(context, [arg1, arg2]);
}
2) , this, . ( "".)
, :
this.fetchData = function()
{
var self = this;
alert(this.a);
getData(getDataCallback);
function getDataCallback(arg1, arg2) {
self.processData(arg1, arg2);
}
}
bind ( , , ). . bind.
: this