JSOOP Object.create 从给定的原型创建对象

80 阅读1分钟
function Shape() {

}
Shape.prototype.duplicate = function() {
  console.log('duplicate')
}
function Circle(radius) {
  this.radius = radius
}

Circle.prototype = Object.create(Shape.prototype)
Circle.prototype.draw = function() {
  console.log('draw')
}
const s = new Shape()
const c = new Circle(1)