Created
March 10, 2016 23:34
-
-
Save kikar/0c0d6d327d3a8d38b383 to your computer and use it in GitHub Desktop.
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 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