5 ms·
You can also create a 'bind' that returns a function that when called applies the context you desire. function bind(fn, selfObj) { return function() {
by joetyson 16y ago
You can also create a 'bind' that returns a function that when called applies the context you desire.
function bind(fn, selfObj) {
return function() {
return fn.apply(selfObj || window);
};
}
callback = bind(function(){ alert(this.hello); }, this);