Created
June 10, 2014 13:06
-
-
Save stdclass/77fb7be98dd901769d0a to your computer and use it in GitHub Desktop.
Javascript Scope
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
var test = { | |
name: "foo", | |
sayHello: function(){ | |
console.log("my name: " + this.name); | |
} | |
}; | |
test.sayHello(); // -> my name: foo | |
var eineKopie = test.sayHello; | |
eineKopie(); // -> my name: | |
// so ruft jquery die callbacks auf | |
var someCallback = function( sagHallo ){ | |
sagHallo(); | |
}; | |
someCallback(test.sayHello); // my name: | |
someCallback($.proxy(test.sayHello, test)); // my name: foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment