functionPerson(){}Person.prototype.run=function(){console.log('run')}functionAnimale(){}Animale.prototype=Person.prototype//為什么不推薦這樣直接改變某個函數(shù)的原型Animale.prototype.eat=function(){console.log('eat')}console.log(newAnimale().run())Animale.prototype=Person.prototype這一句正確的寫法應(yīng)該是vartempFunc=function(){}tempFunc.prototype=Person.prototypeAnimale.prototype=newtempFunc()為什么需要這個tempFunc,直接Animale.prototype=Person.prototype這樣賦值為什么是有問題的?
b.prototype=a.prototype 為什么不能直接這樣賦值
阿晨1998
2019-05-07 09:12:11