function Box(name,age) {    this.name=name;    this.age=age;}Box.PRototype.run=function () {//寫成原型,方便節省內存空間。    return this.name+this.age+'正在運行中!';}function Desk(name,age,passWord) {    this.password=password;    Box.call(this,name,age);//對象冒充.    this.changePW=function () {        return this.password;    }}Desk.prototype=new Box();//原型繼承,實現多個實例化只需分配一次地址,節省內存空間。var desk=new Desk('等等',110,1122);//以下是測試:alert(desk.run());alert(desk.changePW());alert(desk.age);alert(desk.name);alert(desk.password);
新聞熱點
疑難解答