JS实现继承
2019-10-29 本文已影响0人
贪恋冬天的幸福
function Parent () {
this.name = 'Parent';
this.play = [1, 2, 3];
}
function Child () {
Parent.call(this);
this.type = 'Child';
}
Child.prototype = new Parent();
let s = new Child();
let s1 = new Child();
s.play.push(4);
console.log(s.play, s1.play);

