首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

自个儿动手-Javascript面向对象-继承

2012-10-26 
自己动手-Javascript面向对象-继承function Person(){this.namehahathis.sextboythis.getNamefun

自己动手-Javascript面向对象-继承

function Person(){this.name="haha";this.sext="boy";this.getName=function(){alert(this.name);}this.classroom="Person classroom"};function Student(){};Student.prototype=new Person();Student.prototype.classroom="Student room";var student1=new Student();var student2=new Student();alert("student1-classroom-->"+student1.classroom);alert("student2-classroom-->"+student2.classroom);alert("开始修改");student1.classroom="这是student1 room";alert("student1-classroom-->"+student1.classroom);alert("student2-classroom-->"+student2.classroom);

?

热点排行