鉴于以下代码,是否可以从“子”对象内部访问对象的属性?
我想我这样做是完全错误的,但我不确定这里的正确模式是什么。任何帮助将非常感激。
function MainObject(){
this.someProperty = "asdf";
return this;
}
MainObject.prototype.subClass = {};
MainObject.prototype.subClass.sayHi = function(){
// 'this' refers to the instance of MainObject.subClass
// How do I get to the instance's MainObject.someProperty property from here,
// without calling "widget.someProperty"?
};
widget = new MainObject();