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

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

求解釋下面js中的枚舉類型的代碼是什么意思?

求解釋下面js中的枚舉類型的代碼是什么意思?

徐錦杰 2017-03-03 23:39:07
<!DOCTYPE?html> <html> <head> <meta?charset="utf-8"> <title></title> <script?type="text/javascript"> function?inherit(p){ if(p==null)?throw?TypeError(); if(Object.create)?return?Object.create(p); var?t=typeof?p; if(t!=="object"&&?t!=="function")?throw?TypeError(); function?f(){}; f.prototype=p; return?new?f(); } function?enumeration(namesToValues){ var?enumeration=function(){throw?"can't?instantiate?enumeration"}; var?proto=enumeration.prototype={ constructor:enumeration, toString:function(){return?this.name;}, valueOf:function(){return?this.value;}, toJSON:function(){return?this.name;} }; enumeration.values=[]; for(name?in?namesToValues){ var?e=inherit(proto);? e.name=name;????? e.value=namesToValues[name];? enumeration[name]=e; enumeration.values.push(e); } enumeration.foreach=function(f,c){ for?(var?i=0;i<this.values.length;i++) f.call(c,this.values[i]); }; return?enumeration;// } var?Coin=enumeration({Penny:1,Nickel:5,Dime:10,Quarter:25}); var?c=Coin.Dime; console.log(c?instanceof?Coin); console.log(c.constructor==?Coin); console.log(c); console.log(Coin.Nickel); console.log(Coin.values); console.log(Coin.Nickel==5);? console.log(Coin.Nickel+Coin.Penny);?????//==6 </script> </head> <body> </body> </html>這里Coin.Nickel,Coin.Penny都是類屬型,值是一個(gè)對(duì)象,為什么可以相加呢?
查看完整描述

2 回答

  • 2 回答
  • 0 關(guān)注
  • 1963 瀏覽
慕課專欄
更多

添加回答

舉報(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)