国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

javascript - JS? ??? ? ??? ?? ??
我想大聲告訴你
我想大聲告訴你 2017-06-26 10:53:14
0
5
888
????

??? ??? ?? superSay.call(this)為什么會(huì)是People.prototype.say函數(shù)被調(diào)用?this? ???? ??? ??????

我想大聲告訴你
我想大聲告訴你

?? ??(5)
曾經(jīng)蠟筆沒(méi)有小新

??? ?? Student{}類,這個(gè)你可以在superSay.call(this)上面加一行console.log(this)? ?????.

?? ? ??? ???????

???

??? ??? ??? ?? ???? new People()? ??? ????? Instance X?? ????. new People()創(chuàng)建的實(shí)例稱為實(shí)例X
由于superSay = Student.prototype.say,因?yàn)樯厦娴?code>Student.prototype = new People();,所以其中Student.prototype實(shí)例X
所以實(shí)際上superSay調(diào)用的是實(shí)例Xsay,而并非People.prototype.saysuperSay = Student.prototype.say?? ?? Student.prototype = new People();??? Student.prototype? InstanceX.

??? superSay? People.prototype.say? ?? Instance X? say? ?????.

People.prototype.say,主要還是原型鏈的問(wèn)題。實(shí)例X是People類的一個(gè)實(shí)例,所以實(shí)例X的所有方法會(huì)從People類的原型鏈“繼承”(用繼承這個(gè)詞,但是實(shí)際上JS的原型鏈和繼承還是有些區(qū)別的)。所以實(shí)例X.say如果沒(méi)有針對(duì)實(shí)例X重寫say方法,那么實(shí)例Xsay就和People.prototype.say???? ?? ????? ???? ???

.

superSay.call(this)這個(gè)里面的call,只是改變了this的上下文而已。但是由于superSay實(shí)例X.say,這個(gè)方法里根本沒(méi)有this,所以this??

???? ??? ?? ??? ??? ??? ????.

??
迷茫

? ??? js?? ?? ?????

代言

?? ??: ?? say ???? ?? ?? ??? ?? ???? ?????. s——student.prototype——people.prototype——Object? ??? ??? ? ??? ??? ?????. ??? ???? Student.prototype? ?? ? ????. ???? ?? ??? ??? ?? ???? ? ???? ?? ? ????.

???

?? ??? ???? ????. ?? s.say() - 321? ????, s.jiao() - 456? ?????. ?? ?? Student.prototype.say ???? ????? ??? ??? ???? ? ??? ?????

???

? ?? ?? superSay.call(this), ?? superSay? ????, ?? ??? ?????. var superSay = Student.prototype.say ?? console.log(typeof supperSay) ??? ???? ???. , ??? ? ??? ???? ? ??? Student.prototype.say? ?????. var superSay = Student.prototype.say? ?????. ??? ??? ??? ?? People.prototype.say???. ? ?? Elevation? 166-167?????? ?????. ? ?? ???? ??? ? ??? ???? ???? ???? ???? ?? ? ????.

???

? ? superSay? ???? ??? ?????. var superSay = Student.prototype.say? ??? ? Student.prototype?? ??? ??? ??? ?? say ???? ?? ?????. ?? ?? ??? ???? People.prototype.say? superSay

? ?????. ???
我想大聲告訴你

superSay ????? ??? Student.prototype? ??????.

洪濤

??? ??? ???? ????? ??? ??????

?? ?????? stuSay? ??? ?? ?? function(){alert("hello");}? ?????. stuSay? ?? ???? ?? ?, ??? ???? ?? ? ?? ??? ?????. , ?? ?????. ??? ??? ?? ?? ???? ??? ?????? Rhinoceros ?? ?????...

??? ?? ?? ??? ??? ???? ?? ??? ?? ????. ??? ?? ?? ?? ? ?? ?? ??? ???? ????? ?? ???