摘要:
问题:为什么要继承?js中继承的方式有哪些?1为什么要继承?原则是什么?1 reduce the amount of duplicate code 2 make your objects as loosely coupled as possible总的原则:减少重复代码,减少耦合2继承的方式 ?2.1类式继承,一步一步来改进2.11继承最简单的方式。 functionA1(){}A1.prototype={}functionA2(){}A2.prototype=newA1;2.12 继承常用的方式—组合继承如果上面的代码中, function A1(this.colors=["red 阅读全文