Skip to content

Instantly share code, notes, and snippets.

@vstarck
Created August 22, 2011 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vstarck/1163394 to your computer and use it in GitHub Desktop.
Save vstarck/1163394 to your computer and use it in GitHub Desktop.
Bind Decorator
function bindDecorator(fn, scope) {
return function() {
fn.apply(scope, arguments);
}
}
var o = {
k:function() {
console.log(this);
},
toString: function() {
return 'ME!'
}
}
setTimeout(o.k, 0); // Window
setTimeout(bindDecorator(o.k, o), 0); ME!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment