收藏本站 收藏本站
积木网首页 - 软件测试 - 常用手册 - 站长工具 - 技术社区
积木学院 > 程序开发 > jQuery > 正文

js里的prototype使用示例

来源:互联网 日期:2014-11-15 17:37
 
<script type="text/javascript">
function people(name){
this.name=name;
this.introduce=function(){ //对象方法
alert("my name is"+this.name);
}
}

people.run=function(){ //类方法
alert("i can run");
}

people.prototype.jump=function(){ //原型方法
alert("i can jump")
}

var p1=new people("vincent");
p1.introduce();
people.run(); //c#中的static
p1.jump();
</script>

 
function common(){
//.....
}
common.prototype=new Object();

Object对象是common的原型,Object对象的属性和方法复制到了common上

推荐阅读

 

热点信息

 
强悍的草根IT技术社区,这里应该有您想要的!
Copyright © 2010 Gimoo.Net. All Rights Rreserved  京ICP备05050695号