function constructor () {
    var private_v; // 私有属性
    var private_f = function () { // 私有方法
        // code
    };

    this.public_v; // 共有属性
    this.public_f = function () { // 共有方法
    };  

    this.privileged_f = function () { // 特权方法
        private_f ();
    }
}

constructor.prototype.public_v; // 原型共有属性
constructor.prototype.public_f = function () { // 原型共有方法
    };

constructor.static_v; // 类属性
constructor.static_f; // 类方法

  

看完代码应该清楚了

  • 私有方法无访问限制,但是在类外不可调用
  • 共有方法无访问限制,类外也可以调用
  • 原型共有方法,无法访问私有属性和方法,类外可以调用

相关文章:

  • 2022-12-23
  • 2021-08-17
  • 2021-08-17
  • 2021-12-02
  • 2021-08-17
  • 2021-08-12
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-27
  • 2022-12-23
  • 2021-08-17
  • 2021-05-23
  • 2021-08-10
  • 2022-01-18
相关资源
相似解决方案