代码如下:varA=function(){this.a="aaa";varb="bbb";varc="ccc";this.getC=function(){return(c);}}A.prototype={getA:function(){return(this.a);},getB:function(){return(this.b);}}vara1=newA();console.log(a1.getA());//aaaconsole.log(a1.a);//aaaconsole.log(a1.getB());//undefinedconsole.log(a1.b);//undefinedconsole.log(a1.getC());//cccconsole.log(a1.c);//undefined变量A可以作为public变量变量C可以作为private变量有没有办法在prototype原型方法中访问到private对象呢?
添加回答
举报
0/150
提交
取消