Skip to content

Instantly share code, notes, and snippets.

@jpcody
Created July 27, 2011 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpcody/1109820 to your computer and use it in GitHub Desktop.
Save jpcody/1109820 to your computer and use it in GitHub Desktop.
// create a master object
var myObj = {};
myObj.nestedObj = {};
// create a nested object
myObj.nestedObj = {
myReturns : {
first : 'foo',
second : 'bar'
},
myCaller : function(){
return this.myWrapper.doBind();
},
myWrapper : {
doBind : function(){
console.log(this);
// this is the global scope, presumably because bind is executed before, er, I'm not sure.
return this.first;
}
}
};
_.bind(myObj.nestedObj.myWrapper.doBind, myObj.nestedObj);
myObj.nestedObj.myCaller();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment