Skip to content

Instantly share code, notes, and snippets.

@kikar
Created March 10, 2016 23:41
Show Gist options
  • Save kikar/b536d95760238a4c2d1e to your computer and use it in GitHub Desktop.
Save kikar/b536d95760238a4c2d1e to your computer and use it in GitHub Desktop.
function foo() {
console.log( this.a );
}
var obj = {
a: 2
};
var foo2 = foo.bind(obj);
var obj2 = {
a: 3,
foo2: foo2
};
foo2(); // 2
obj2.foo2(); // 2
foo2.call(obj2); // 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment