JavaScript中利用prototype属性扩展对象功能示例.pdfVIP

  • 1
  • 0
  • 约1.15千字
  • 约 4页
  • 2026-06-29 发布于北京
  • 举报

JavaScript中利用prototype属性扩展对象功能示例.pdf

prototype属性使您有能力向对象添加属性和方法

functionuser(age,){this.name=;

this.age=age;this.=;this.eat=

function(){//方法体alert(我是user中的吃

的方法)}}functionuser2(){this.run=

function(){alert(我是user2中跑的方法);}}

user.prototype=newuser2();//创建对象

varus=newuser(12);us.look=看;//

js中对象的使用比较灵活

prototype属性使您有能力向对象添加属性和方法

functionuser(age,){

this.name=;

this.age=age;

this.=;

文档评论(0)

1亿VIP精品文档

相关文档