Consider the following code:
function A() {} A.prototype.go = function() { console.log(this); //A { go=function()} var f = function() {
The scope of all functions is window.
window
To circumvent that, you can do this:
function A() {} A.prototype.go = function() { var self = this; console.log(self); //A { go=function()} var f = function() { console.log(self); //A { go=function()} }; f(); }