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

javascript 种继承机制

2012-07-02 
javascript 类继承机制Javascript类的继承是通过constructor和prototype来实现的1. 定义一个形如java的per

javascript 类继承机制
Javascript类的继承是通过constructor和prototype来实现的

1. 定义一个形如java的person类,然后实例化和调用它的属性
  

   // Set the property of the prototype of man    man.prototype.name = 'changed value';   // The property of the instance of subclass wouldn't be changed   alert(m1.name);   // The property of the prototype has been changed   alert(p1.name);   

   原型对象的属性被改变,但是子类对象没有。
   执行结果是:
   susceptibility
   changed value
  

热点排行
Bad Request.