Unikanie zmiany kontekstu callback
by Torwan
JavaScript
function Car() {
// constructor
var __construct = function(that) {
var _this = that;
that.getSpeed = function() {
return _this._getSpeed();
};
}(this);
this._getSpeed = function() {
alert("100 mph");
};
}
var car = new Car();
function process(callback) {
callback();
}
process(car.getSpeed);