公共属性与javascripts中的Prototype属性

时间:2014-10-13 20:17:05

标签: javascript prototype

有没有理由在javascripts中使用公共属性?

当我们比较时,

funtion A() {
this.a = 'lol'; //public proeprty. it will use memory space per object. right?
}

function B() {
}
B.prototype.b ='lol'; //prototype property. it will share same memory address until new value is setted. right?

for(var i = 0; i < 10; i++) { aa[i] = new A(); bb[i] = new B(); }

B的实现在内存中非常有效,并且可访问性没有区别。那么,有没有理由使用公共财产?

0 个答案:

没有答案