prototype用法總結

function classA(a,b,c){
	if(a)this.a = a;
	if(b)this.b = b;
	if(c)this.c = c;
	this.reset = function(){
		for(var each in this){
			delete this[each];
		}
	}
}
classA.prototype.a = 10;
classA.prototype.b = 20;
classA.prototype.c = 30;

var a = new classA();
alert(a.a);
a.a *=2;
a.b *=2;
a.c *=2;
alert(a.a);
alert(a.b);
alert(a.c);
a.reset();
alert(a.a);
alert(a.b);
alert(a.c);
})


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章