基于构造函数的五种继承方法小结
1.使用call或apply绑定构造函数 animal.apply(this.arguments) 2.使用prototype属性 Cat.prototype = new Animal(); Cat.prototype.constructor = Cat; var cat1 = new Cat("大毛","黄色"); alert(cat1.species); // 动物 3.直接集成prototype属性 function Animal(){ } Animal.prototype.species = "动物"; Cat.protot
下载地址
用户评论