Object.create() 为新对象,提供现有对象的__proto__
Object.create()
方法创建一个新对象,使用现有的对象来提供新创建的对象的__proto__
function Animal () {} function Dog () {} Dog.prototype = Object.create(Animal.prototype) document.write(Dog.prototype instanceof Animal)
Object.create()
方法创建一个新对象,使用现有的对象来提供新创建的对象的__proto__
function Animal () {} function Dog () {} Dog.prototype = Object.create(Animal.prototype) document.write(Dog.prototype instanceof Animal)