Skip to content

Instantly share code, notes, and snippets.

@stdclass
Created June 10, 2014 13:06
Show Gist options
  • Save stdclass/77fb7be98dd901769d0a to your computer and use it in GitHub Desktop.
Save stdclass/77fb7be98dd901769d0a to your computer and use it in GitHub Desktop.
Javascript Scope
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