理解js对象继承的N种模式
本文分享了js对象继承的N种模式,供大家参考。 一、原型链继承 function Person(){}; Person.prototype = { constructor: Person, name: "Oliver" }; function People(){}; People.prototype = new Person(); People.prototype.constructor = People; People.prototype.sayName = function(){ return this.name; }; var ins = new People(); con
用户评论