Created
November 15, 2014 10:02
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 val = "window.val" | |
var obj = { | |
val: "obj.val", | |
innerMethod: function () { | |
var val = "obj.val.inner", | |
func = function () { | |
var self = this; | |
return self.val; | |
}; | |
return func; | |
}, | |
outerMethod: function () { | |
return this.val; | |
} | |
}; | |
//This actually gets executed inside window object | |
console.log(obj.innerMethod()()); //returns window.val | |
//Breakdown in to 2 lines explains this in detail | |
var _inn = obj.innerMethod(); | |
console.log(_inn()); //returns window.val | |
console.log(obj.outerMethod()); //returns obj.val |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment