标签:blog io java ar div cti sp log on
var animal=function(name){ //构造函数 this.name=name; this.sayhello=function(){ alert("hi我是"+this.name); }; } animal.prototype.shout=function(){ //prototype主要作用:给类增加一个新的属性或函数 alert(this.name+"正在叫!"); }; animal.prototype.game=function(){ alert(this.name+"正在玩耍!"); }; var dog=new animal("小黑"); //实例化 dog.sayhello(); dog.shout(); dog.game();
var animal=function(name){
this.name=name;
this.sayhello=function(){
alert("hi我是"+this.name);
};
}
animal.prototype.shout=function(){
alert(this.name+"正在叫!");
};
animal.prototype.game=function(){
alert(this.name+"正在玩耍!");
};
var dog=new animal("小黑");
dog.sayhello();
dog.shout();
dog.game();
标签:blog io java ar div cti sp log on
原文地址:http://www.cnblogs.com/zhangwenkan/p/3956620.html