Skip to content

Instantly share code, notes, and snippets.

@mrlannigan
Created December 17, 2013 16:15
Show Gist options
  • Save mrlannigan/8007556 to your computer and use it in GitHub Desktop.
Save mrlannigan/8007556 to your computer and use it in GitHub Desktop.
function bind (scope, func) {
return function () {
func.apply(scope, arguments);
};
}
function A() {
this.console.log('hello A, I\'m logging my output via my this because it is bound to the global context');
}
function B() {
console.log('hello B, here is my this:', this);
}
A = bind(global, A);
B = B.bind({blankObject:true});
// run them
A();
B();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment