源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

js里的prototype使用示例

  • 时间:2021-11-26 08:32 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:js里的prototype使用示例
[u]复制代码[/u] 代码如下:
<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>
[u]复制代码[/u] 代码如下:
function common(){ //..... } common.prototype=new Object();
Object对象是common的原型,Object对象的属性和方法复制到了common上
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部