标题有点模棱两可,但代码非常清楚地解释了这个问题:
function Game() {
this.secret = '';
this.Playground = {
this.someTreat: function() {
console.log('how to access secret from here ?');
}
};
}
var Test = new Game();
Test.Playground.someTreat();
我提供了一个具有相同代码的JSFiddle 。