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

相关文章:

  • 2021-08-11
  • 2021-08-20
  • 2021-07-31
  • 2022-01-20
  • 2021-12-05
猜你喜欢
  • 2022-12-23
  • 2021-09-29
  • 2021-09-03
  • 2021-08-16
  • 2021-12-03
  • 2021-08-12
  • 2022-01-16
相关资源
相似解决方案