Created
July 27, 2011 16:55
-
-
Save jpcody/1109820 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
// 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