Skip to content

Instantly share code, notes, and snippets.

@olenhad
Created February 12, 2014 14:27
Show Gist options
  • Save olenhad/8956472 to your computer and use it in GitHub Desktop.
Save olenhad/8956472 to your computer and use it in GitHub Desktop.
A Micro Treatise on Scoping in JS
var O = {
foo : function (callback){
callback();
},
bar : function () {
this.baz();
},
baz: function () {
console.log("fml");
},
main : function () {
this.foo(this.bar);
}
}
O.main();
// for added fun, add a console.log(this) to O.bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment