1. 程式人生 > >prototype屬性

prototype屬性

asc function highlight prot introduce var chinese type屬性 log

function People(name){

	this.name=name;
	//對象方法
	this.Introduce=function(){
		console.log(this.name);
	}
}
//類方法
People.Run=function(){
	console.log("I can run");
}
//原型方法
People.prototype.IntroduceChinese=function(){
	console.log(this.name);
}
 
//測試
var p1 = new People(‘132‘);
p1.Introduce();//132
People.Run();//I can run
p1.IntroduceChinese();//132

  

prototype屬性