function TestClassA(name, number) {  

       this.name = name;             //public  

       this.number = number;         //public  

       var account = '';             //private  

       var phone = '13612345678';    //private  

       this.getAccount = function() {  

              return account;  

      }  

       this.setAccount = function (a) {  

              account = a;  

      }  

  }  

私有化属性是指,每个对象在调用这个属性时都得先set进去值然后再获取,并且不是公用的。

公共属性是,每个新构造的对像访问的都是一个属性,公用的

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-28
  • 2021-10-10
  • 2021-09-07
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-07-27
  • 2022-12-23
  • 2021-09-29
  • 2021-12-10
  • 2021-11-15
  • 2021-09-19
相关资源
相似解决方案