MyClass = function () {
    var A = 1;           //内部成员
    B = 2;               //内部成员
    this.C = 3;          //对象成员
}
MyClass.prototype.D = 4; //对象成员(通过原型扩展)

obj = new MyClass();
alert(obj.A); //undefined
alert(obj.B); //undefined
alert(obj.C); //3
alert(obj.D); //4

alert(obj.hasOwnProperty('C')); //true
alert(obj.hasOwnProperty('D')); //false

相关文章:

  • 2022-01-13
  • 2022-01-07
  • 2022-12-23
  • 2021-07-27
  • 2021-08-15
猜你喜欢
  • 2021-08-31
  • 2021-07-09
  • 2022-12-23
  • 2021-10-15
  • 2021-05-30
  • 2021-07-30
相关资源
相似解决方案