Skip to content

Instantly share code, notes, and snippets.

@kikar
Created March 10, 2016 23:34
Show Gist options
  • Save kikar/0c0d6d327d3a8d38b383 to your computer and use it in GitHub Desktop.
Save kikar/0c0d6d327d3a8d38b383 to your computer and use it in GitHub Desktop.
function foo() {
console.log( this.a );
}
function doFoo(fn) {
fn();
}
function doFoo2(fn, that) {
fn.call(that);
}
var obj = {
a: 2,
foo: foo
};
var a = 4;
doFoo( obj.foo ); // 4
doFoo2( obj.foo, obj ); // 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment