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 為什么不能直接這樣賦值,而需要使用另外一個函數(shù)轉(zhuǎn)一下
函數(shù)式編程
2019-04-27 17:17:01