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
