Created
August 22, 2011 20:10
-
-
Save vstarck/1163394 to your computer and use it in GitHub Desktop.
Bind Decorator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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