function Test() { this.str = 'test'; } Test.prototype = { fn1: function() { alert(this.str); }, fn: { var self = this; fn2: function() { alert(self.str); } } }; new Test().fn.fn2();