MyClass = function () {
this.A = 1;
}
MyClass.prototype.X = function () {
this.B = 2;
}
MyClass.prototype.Y = function () {
this.Z = function () {
this.C = 3;
}
}
/* 内部对象的 this ? */
obj = new MyClass();
alert(obj.A); //1
obj1 = new obj.X();
alert(obj1.B); //2
obj2 = new (new obj.Y()).Z();
alert(obj2.C); //3
/* 所属对象的 this ? */
obj = new MyClass();
obj.X();
obj.Y();
obj.Z();
alert(obj.A); //1
alert(obj.B); //2
alert(obj.C); //3
转载于:https://my.oschina.net/hermer/blog/319567