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);
s 实例对象
s1 实例对象
上一篇 下一篇

猜你喜欢

热点阅读