function object(o) { function F() {} F.prototype = o; return new F(); } function creatAnother(original) { var clone = object(original); clone.sayHi = function() { alert('Hi!'); }; return clone; } var student1 = { school: 'HNU', saySchool: function() { return this.school; } }; var student2 = creatAnother(student1);
原型式继承和寄生式继承用于创建与已有对象类似的实例对象。
您可能感兴趣的文章: