第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

javascript原型繼承問(wèn)題,問(wèn)題在下面代碼注釋里,麻煩大家了,謝謝

javascript原型繼承問(wèn)題,問(wèn)題在下面代碼注釋里,麻煩大家了,謝謝

yuqingzhijie3596863 2017-03-22 10:10:23
<script type="text/javascript">? ? ? ? ? ? ? ? ? ??? ? ? ? function SuperType(name){? ? ? ? ? ? this.name = name;? ? ? ? ? ? this.colors = ["red", "blue", "green"];? ? ? ? }? ? ? ??? ? ? ? SuperType.prototype.sayName = function(){? ? ? ? ? ? alert(this.name);? ? ? ? };? ? ? ? function SubType(name, age){ ?? ? ? ? ? ? SuperType.call(this, name);? ? ? ? ? ??? ? ? ? ? ? this.age = age;? ? ? ? }????????//---------------------------------問(wèn)題在下一行------------------------------? ? ? ? //SubType.prototype = new SuperType();//這里我特意注釋掉,然后我覺(jué)得subtype實(shí)例應(yīng)該不能調(diào)用sayAge和sayName方法了,但實(shí)際能正常調(diào)用sayAge,而不能掉用sayName,為什么??? ? ? ??? ? ? ? SubType.prototype.sayAge = function(){? ? ? ? ? ? alert(this.age);? ? ? ? };? ? ? ??? ? ? ? var instance1 = new SubType("Nicholas", 29);? ? ? ? instance1.colors.push("black");? ? ? ? alert(instance1.colors); ?//"red,blue,green,black"? ? ? ? //instance1.sayName(); ? ? ?//"Nicholas";? ? ? ? instance1.sayAge(); ? ? ? //29//調(diào)用sayAge正常運(yùn)行,不會(huì)報(bào)錯(cuò)? ? ? ? ??? ? ? ? var instance2 = new SubType("Greg", 27);? ? ? ? alert(instance2.colors); ?//"red,blue,green"? ? ? ? instance2.sayName(); ? ? ?//"Greg";//調(diào)用sayName會(huì)報(bào)錯(cuò)? ? ? ? instance2.sayAge(); ? ? ? //27? ? ? ?? ? ? ??? ? </script>
查看完整描述

1 回答

  • 1 回答
  • 1 關(guān)注
  • 1002 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)