继承
1. 原型链
Child.prototype = new Father();
Child.prototype.constructor = Child;
2. 构造函数
Father.call(Child);
3. 组合
Father.call(Child);
Child.prototype = new Father();
Child.prototype.constructor = Child;
4. 探索
Father.call(Child);
Child.prototype = Father.prototype;
Child.prototype.constructor = Child;
5. 成功
Father.call(Child);
Child.prototype = Object.create(Father.prototype)//以Father.prototype对象为原型,生成了Child.prototype对象
Child.prototype.constructor = Child;
(function () {
// 创建一个没有实例方法的类
var Super = function () { };
Super.prototype = Father.prototype;
//将实例作为子类的原型
Child.prototype = new Super();
Child.prototype.constructor = Child;
})();
6. 升级Class