javascript的方法

 javascript的方法能夠分爲三類:javascript

a 類方法java

b 對象方法測試

c 原型方法this

function People(name)
{
  this.name=name;
  //對象方法
  this.Introduce=function(){
    alert("My name is "+this.name);
  }
}
//類方法
People.Run=function(){
  alert("I can run");
}
//原型方法
People.prototype.IntroduceChinese=function(){
  alert("個人名字是"+this.name);
}
 
//測試
var p1=new People("lll");
p1.Introduce();
People.Run();
p1.IntroduceChinese();
相關文章
相關標籤/搜索