å 容
- ã¯ããã«
- å€ãã¿ã€ããããã³æŒç®å
- ããã°ã©ã æ§æ
- æ©èœ
- ããŒã¿æ§é ïŒãªããžã§ã¯ããšé å
- é«éé¢æ°
- ãªããžã§ã¯ãã®ç§å¯ã®ç掻
- ãããžã§ã¯ãïŒé»åç掻
- æ€çŽ¢ãšãšã©ãŒåŠç
- æ£èŠè¡šçŸ
- ã¢ãžã¥ãŒã«
- ãããžã§ã¯ãïŒããã°ã©ãã³ã°èšèª
- JavaScriptãšãã©ãŠã¶ãŒ
- ããã¥ã¡ã³ããªããžã§ã¯ãã¢ãã«
- ã€ãã³ãåŠç
- ãããžã§ã¯ãïŒãã©ãããã©ãŒã ã²ãŒã
- ãã£ã³ãã¹ã«æã
- HTTP
- ãã©ãŒã ãšãã©ãŒã ãã£ãŒã«ã
- ãããžã§ã¯ãïŒãã€ã³ã
- Node.js
- ãããžã§ã¯ãïŒçµéšå ±æãŠã§ããµã€ã
- ã³ãŒãã®ãµã³ãããã¯ã¹
ããã°ã©ã ãæ©æ¢°ã®è¡šé¢ã®äžã移åããŸãã åªåãªãã§ãããã¯æ¡å€§ããã³çž®å°ããŸãã é»åã¯éåžžã«èª¿åããŠãããæ£ä¹±ããŠåéããŸãã ã¢ãã¿ãŒäžã®ãã©ãŒã ã¯ãæ°Žäžã®æ³¢çŽã§ãã æ¬è³ªã¯å éšã«é ããããŸãŸã§ã...
ãã¹ã¿ãŒãŠã¢ã³ããŒãããã°ã©ãã³ã°æ¬
ã³ã³ãã¥ãŒã¿ãŒã®äžçã«ã¯ããŒã¿ãããããŸããã ããŒã¿ã®èªã¿åããããŒã¿ã®å€æŽãæ°ããããŒã¿ã®äœæãã§ããŸã-ããããããŒã¿ä»¥å€ã«ã¯äœããããŸããã ãã¹ãŠã®ããŒã¿ã¯ãããã®é·ãã·ãŒã±ã³ã¹ãšããŠä¿åããããããäºãã«é¡äŒŒããŠããŸãã
ãããã¯2ã€ã®ç¶æ ãæã€ãšã³ãã£ãã£ã§ãããéåžžã¯0ãš1ãšããŠèšè¿°ãããŸãã ã³ã³ãã¥ãŒã¿ãŒã§ã¯ãé«é»è·ãšäœé»è·ã匷ãä¿¡å·ãšåŒ±ãä¿¡å·ããŸãã¯CDã®è¡šé¢ã®å æ²¢ã®ããããããªé åã®åœ¢ã§çããŠããŸãã åæ å ±ã¯ããŒããš1ã®ã·ãŒã±ã³ã¹ãã€ãŸãããããšããŠè¡šãããšãã§ããŸãã
ããšãã°ãæ°åã®13ã§ãã10æ¡ã§æ§æããã10é²æ°ã·ã¹ãã ã®ä»£ããã«ã2æ¡ã®ãã€ããªã·ã¹ãã ããããŸãã æ°å€ã®åäœçœ®ã®å€ã¯ãå³ããå·Šã«ç§»åãããšåã«ãªããŸãã çªå·13ãæ§æããããããšãã®éã¿ïŒ
0 0 0 0 1 1 0 1 128 64 32 16 8 4 2 1
2é²æ°00001101ãã€ãŸã8 + 4 + 1ãã€ãŸã13ã§ãã
æ°éã
ããããã®ããããæ³åããŠãã ããã å žåçãªææ°ã®ã³ã³ãã¥ãŒã¿ãŒã¯ã300åããã以äžãRAMã«ä¿åããŸãã éåžžãæ°žç¶ã¡ã¢ãªïŒããŒããã£ã¹ã¯ïŒã¯ãæ°æ¡å€§ãããªããŸãã
è¿·åã«ãªããã«äœæ¥ããããã«ãæ å ±ã®åäœãè¡šãæçã«åå²ã§ããŸãã JavaScriptã§ã¯ããããã®åäœã¯æ°éãšåŒã°ããŸãã ãããã®å€ã¯ãã¹ãŠãããã§æ§æãããŠããŸãããç°ãªã圹å²ãæãããŸãã åæ°éã«ã¯ããã®åœ¹å²ã決å®ããã¿ã€ãããããŸãã åèšã§6ã€ã®äž»ãªã¿ã€ãããããŸãïŒæ°å€ãæååãããŒã«å€ããªããžã§ã¯ããé¢æ°ãããã³äžå®å€ã§ãã
å€ãäœæããã«ã¯ããã®ååãæå®ããå¿ èŠããããŸãã ããã¯äŸ¿å©ã§ãã 建ç¯ææãåéããããããããæ¯æãå¿ èŠã¯ãããŸããã é»è©±ããã ãã§ã-op-paãå®äºã§ãã ãããã¯ç©ºããäœæããããã®ã§ã¯ãããŸãã-åå€ã¯ã©ããã«ä¿åãããŠãããèšå€§ãªæ°ã䜿çšãããå Žåãããããäžè¶³ããå¯èœæ§ããããŸãã 幞ããªããšã«ãããã¯ãã¹ãŠãåæã«å¿ èŠãªå Žåã®ã¿ã§ãã æ°éãäžèŠãªå Žåã¯ãæ°éã解æ¶ããã䜿çšãããããããæ°ããæ°éã®å»ºç¯ææãšããŠåŠçã«éãããŸãã
ãã®ç« ã§ã¯ãJavaScriptããã°ã©ã ã®ã¢ãã âåçŽãªã¿ã€ãã®å€æ°ãšãããã«é©çšãããæŒç®åã玹ä»ããŸãã
æ°å
æ°å€åã®å€ãããã¯é©ãã§ã-æ°å€ã JavaScriptããã°ã©ã ã§ã¯ã次ã®ããã«èšè¿°ãããŸã
13
ããã°ã©ã ã§ãã®ãšã³ããªã䜿çšãããšãã³ã³ãã¥ãŒã¿ãŒã®ã¡ã¢ãªã«13ãšããæ°åãè¡šãäžé£ã®ãããã衚瀺ãããŸãã
JavaScriptã¯ãåºå®ãããæ°ïŒ64ïŒã䜿çšããŠæ°å€ãæ ŒçŽããŸãã 64ãããã䜿çšããŠè¡šçŸã§ããæ°éã®æ°ã¯å¶éãããŠããŸããã€ãŸããæ°èªäœãå¶éãããŠããŸãã Næ¡ã®10é²æ°ã®å Žåãæžã蟌ãããšãã§ããæ°åã®æ°ã¯10ã®Nä¹ã§ããåæ§ã«ã64ãããã¯2ã®64ä¹ã®æ°ãè¡šçŸã§ããŸãã ããã¯ããªããããããããŸãã
以åã¯ãã³ã³ãã¥ãŒã¿ãŒã®ã¡ã¢ãªãå°ãªãã8ããããŸãã¯16ãããã®ã°ã«ãŒããæ°å€ã®ä¿åã«äœ¿çšãããŠããŸããã ãã®ãããªå°ããªæ°ã®æ倧æ°ã誀ã£ãŠè¶ ããããšã¯ç°¡åã§ãããã€ãŸãããã®ãããã®ã»ããã«åãŸããªãæ°ã䜿çšããŸããã ä»æ¥ãã³ã³ãã¥ãŒã¿ãŒã«ã¯å€ãã®ã¡ã¢ãªãããã64ãããã®æçã䜿çšã§ããŸãããã®ããã倩æåŠçãªæ°åãæ±ãå Žåã«ã®ã¿ãã®ããšãå¿é ããå¿ èŠããããŸãã
確ãã«ã2 ^ 64æªæºã®ãã¹ãŠã®æ°å€ãJavaScriptã®æ°å€ã«é©åããããã§ã¯ãããŸããã è² ã®æ°å€ããããã®ãããã«æ ŒçŽãããŸãããããã£ãŠã1ãããã«æ°å€ã®ç¬Šå·ãæ ŒçŽãããŸãã ããã«ãåæ°ãä¿åã§ããå¿ èŠããããŸãã ãããè¡ãã«ã¯ããããã®äžéšã䜿çšããŠå°æ°ç¹ã®äœçœ®ãæ ŒçŽããŸãã æ°å€ã®å®éã®æ倧å€ã¯çŽ10 ^ 15ã§ãããäžè¬çã«ã¯ãŸã ã»ãšãã©ã§ãã
åæ°ã¯ãããã䜿çšããŠèšé²ãããŸãã
9.81
éåžžã«å€§ãããŸãã¯å°ããæ°ã¯ãç§åŠè¡šèšæ³ã§æåãeãïŒææ°ïŒãšããã«ç¶ã床ã§æžãããŠããŸãã
2.998e8
ããã¯2.998Ã10 ^ 8 = 299800000ã§ãã
10 ^ 15æªæºã®æŽæ°ïŒæŽæ°ãšãåŒã°ããïŒã䜿çšããèšç®ã¯ãæ£ç¢ºã§ããããšãä¿èšŒãããŠããŸãã éåžžãåæ°ã®èšç®ã¯è¡ãããŸããã æ°ÏïŒpiïŒãæéã®æ¡æ°ã§æ£ç¢ºã«è¡šãããšãã§ããªãããã«ã64ããããããªãå Žåãå€ãã®å°æ°éšãè¡šãããšã¯ã§ããŸããã æªãã§ãããéåžžã«ç¹å®ã®ã±ãŒã¹ã§ã¯éªéã«ãªããŸãã ããã念é ã«çœ®ããŠãåæ°ãè¿äŒŒå€ãšããŠæ±ãããšãéèŠã§ãã
ç®è¡
æ°å€ã䜿çšããŠå®è¡ã§ããäž»ãªããšã¯ãç®è¡èšç®ã§ãã å ç®ãšä¹ç®ã¯2ã€ã®æ°å€ã䜿çšãã3çªç®ã®æ°å€ãäžããŸãã JavaScriptã§ãããèšè¿°ããæ¹æ³ïŒ
100 + 4 * 11
èšå·+ããã³*ã¯æŒç®åãšåŒã°ããŸãã æåã¯å ç®ã2çªç®ã¯ä¹ç®ã§ãã 2ã€ã®éã®éã«æŒç®åãé 眮ããåŒã®å€ãååŸããŸãã
ãŸãããã®äŸã§ã¯ãã4ãš100ãå ç®ããŠããçµæã«11ãæãããããšãããããŸããããããšãä¹ç®ãæåã«å®è¡ãããŸããïŒ ãæ³åã®ãšãããä¹ç®ãæåã«è¡ãããŸãã ããããæ°åŠã®ããã«ãããã¯æ¬åŒ§ã䜿çšããŠå€æŽã§ããŸãã
(100 + 4) * 11
æŒç®å-ã¯æžç®ã«äœ¿çšããã/ã¯é€ç®ã«äœ¿çšãããŸã
æ¬åŒ§ãªãã§æŒç®åã䜿çšããå Žåãå®è¡ãããé åºã¯åªå é äœã«ãã£ãŠæ±ºãŸããŸãã *ããã³/æŒç®åã¯ãåªå é äœãçãã+ããã³-æŒç®åãããé«ãåªå é äœãæã£ãŠããŸãã åªå é äœãåãæŒç®åãèšç®ããå Žåãå·Šããå³ã«èšç®ãããŸãã
1 - 2 + 1
ïŒ1-2ïŒ+ 1ãšããŠèšç®
åªå é äœã«ã€ããŠå¿é ããå¿ èŠã¯ãŸã ãããŸããã çãããå Žåã¯ãæ¬åŒ§ã䜿çšããŠãã ããã
ããã«èªèãããªãå¥ã®æŒç®åããããŸãã ïŒ èšå·ã¯ãæ®ããååŸããããã«äœ¿çšãããŸãã XïŒ Yã¯XãYã§é€ç®ããäœãã§ãã314ïŒ 100ã¯14ãã144ïŒ 12ã¯0ãè¿ããŸããæŒç®åã®åªå é äœã¯ä¹ç®ãšé€ç®ãšåãã§ãã ãã¢ãžã¥ãé€ç®ããšåŒã°ããŸãããããæ£ç¢ºã«ã¯ãå°äœãããã§ãã
ç¹å¥ãªçªå·
JavaScriptã«ã¯3ã€ã®ç¹å¥ãªå€ãããããããã¯æ°å€ãšèŠãªãããŸãããéåžžã®æ°å€ã®ããã«ã¯åäœããŸããã
ãããã¯
Infinity
ãš
-Infinity
ã§ãããæ£ãšè² ã®ç¡éãè¡šããŸãã ç¡é-1 =ç¡éãªã©ã ç¡é倧ã®èšç®ã«å€§ããäŸåããªãã§ãã ãã;ãããã¯å³å¯ãããŸããã
3çªç®ã®æ°å€ïŒ
NaN
ããã¯æ°å€åã®å€ã§ããããæ°å€ã§ã¯ãªããããšã瀺ããŸãã 0/0ãInfinity-InfinityããŸãã¯æ£ç¢ºã§æå³ã®ããçµæããããããªãä»ã®æäœãªã©ã®èšç®åŸã«ååŸã§ããŸãã
è¡
次ã®åºæ¬çãªããŒã¿åã¯æååã§ãã ããã¹ããä¿åããããã«äœ¿çšãããŸãã ãããã¯åŒçšç¬Šã§æžãããŠããŸãïŒ
â , â ' , '
äºéåŒçšç¬ŠãšåäžåŒçšç¬Šã®äž¡æ¹ã䜿çšã§ããŸã-äž»ãªããšã¯ãããããäžç·ã«äœ¿çšããããšã§ãã ã»ãšãã©ãã¹ãŠãåŒçšç¬Šã§å²ã¿ãããããæååãäœæã§ããŸãã ãã ããäžéšã®æåã¯åé¡ãåŒãèµ·ãããŸãã ããšãã°ãåŒçšç¬ŠãåŒçšç¬Šã§å²ãããšã¯å°é£ã§ãã æ¹è¡ããããã«åçŽã«å²ãŸããããšã¯ã§ããŸãã-è¡ã¯1è¡ãšããŠå ¥åããå¿ èŠããããŸãã
ç¹æ®æåãå²ãã«ã¯ãããã¯ã¹ã©ãã·ã¥\ã䜿çšããŸãã ããã¯ãããã«ç¶ãæåãç¹å¥ãªæå³ãæã€ããšãæå³ããŸã-ããã¯ããšã¹ã±ãŒãæåããšåŒã°ããŸãã \ãã¯äºéåŒçšç¬Šã§å²ãããšãã§ããŸãã \ nã¯æ¹è¡ãè¡šãã\ tã¯éèšãè¡šããŸãã
ã1çªç®ãš2çªç®ã®æåã®éã®æåã¯å°ãããªããŸãããšããè¡ã¯ãå®éã«ã¯æ¬¡ã®ããã«ãªããŸãã
æååã«ããã¯ã¹ã©ãã·ã¥ãå«ããå¿ èŠãããå Žåã¯ããšã¹ã±ãŒãããå¿ èŠããããŸãïŒ\\ã ãæ¹è¡æåã¯ã\ nãããšããåœä»€ã¯ã次ã®ããã«èšè¿°ããå¿ èŠããããŸãã
" â \"\\n\""
è¡ãåå²ãä¹ç®ããŸãã¯è¿œå ããããšã¯ã§ããŸããã ãã ãã+æŒç®åãäžç·ã«äœ¿çšãããšãããããçžäºã«æ¥ç¶ã§ããŸãã 次ã®åŒã¯ãæ¥ç¶ããšããåèªãçæããŸãã
"" + "" + "" + ""
æååãæäœããæ¹æ³ã¯å€æ°ãããŸãã第4ç« ã§èª¬æããŸãã
åé æŒç®å
ãã¹ãŠã®æŒç®åãæåã§æžãããŠããããã§ã¯ãããŸãã-äžéšã¯åèªã§æžãããŠããŸãã ãã®ãããªæŒç®åã®1ã€ã«
typeof
ããããé©çšãããå€ã®åã®ååãäžããŸãã
console.log(typeof 4.5) // â number console.log(typeof "x") // â string
çµæãç»é¢ã«è¡šç€ºããå Žåã¯ãäŸã§
console.log
åŒã³åºãã䜿çšããŸãã çµæãã©ã®çšåºŠæ£ç¢ºã«è¿ããããã¯ãã¹ã¯ãªãããå®è¡ããç°å¢ã«ãã£ãŠç°ãªããŸãã
以åã®æŒç®åã¯2ã€ã®å€ã§æ©èœããŸããããtypeofã¯1ã€ã®å€ã®ã¿ã䜿çšããŸãã 2ã€ã®éãæ±ãæŒç®åã¯ãã€ããªãšåŒã°ãã1ã€ã¯åé ãšåŒã°ããŸãã ãã€ãã¹ïŒæžç®ïŒã¯ãåé ãšããŠããã€ããªãšããŠã䜿çšã§ããŸãã
console.log(- (10 - 2)) // â -8
ããŒã«å€
å€ãã®å Žåããã¯ãããšããããããããªã³ããšããªãããªã©ã2ã€ã®å¯èœæ§ã®ãããããåçŽã«ç€ºãå€ãå¿ èŠã§ãã ãããè¡ãããã«ãJavaScriptã«ã¯ããŒã«å€åãããã
true
ãš
false
ïŒtrueãšfalseïŒã®2ã€ã®å€ãããããŸããã
æ¯èŒ
ããŒã«å€ãååŸãã1ã€ã®æ¹æ³ïŒ
console.log(3 > 2) // â true console.log(3 < 2) // â false
èšå·<and>ã¯ãåŸæ¥ããå°ãªããªãããšãæå³ããŸãã ãããã¯äºé æŒç®åã§ãã ãããã䜿çšããçµæãäžçåŒãçã§ãããã©ããã瀺ãããŒã«å€ãååŸããŸãã
æååã¯åãæ¹æ³ã§æ¯èŒã§ããŸãã
console.log("" < "") // â true
æååã¯ã¢ã«ãã¡ãããé ã«æ¯èŒãããŸãã倧æåã®æåã¯åžžã«å°æåã®æåããããå°ããããªããŸãã æ¯èŒã¯Unicodeæšæºã«åºã¥ããŠããŸãã ãã®èŠæ Œã¯ãããããèšèªã®ã»ãŒãã¹ãŠã®ãã£ã©ã¯ã¿ãŒã«çªå·ãå²ãåœãŠãŸãã æååãæ¯èŒãããšããJavaScriptã¯æåãå·Šããå³ã«èª¿ã¹ããããã®æåã®çªå·ã³ãŒããæ¯èŒããŸãã
ä»ã®åæ§ã®æŒç®åã¯ã> =ïŒä»¥äžïŒã<=ïŒä»¥äžïŒã==ïŒçããïŒã! =ïŒçãããªãïŒã§ãã
console.log("" != "") // â true
JavaScriptã«ã¯ãããèªäœãšã¯ç°ãªãå€ã1ã€ã ããããŸã
NaN
ïŒãnot a numberãïŒã
console.log(NaN == NaN) // â false
NaNã¯ç¡æå³ãªèšç®ã®çµæã§ãããããä»ã®ç¡æå³ãªèšç®ã®çµæãšã¯ç°ãªããŸãã
ããŒã«å€èªäœã§å®è¡ã§ããæäœããããŸãã JavaScriptã¯ã次ã®3ã€ã®è«çæŒç®åããµããŒãããŠããŸãã
&&æŒç®åã¯è«ççãªãandãã§ãã ãã€ããªã§ãããé©çšãããäž¡æ¹ã®éãçã§ããå Žåã«ã®ã¿ãçµæã¯çã«ãªããŸãã
console.log(true && false) // â false console.log(true && true) // â true
æŒç®å|| -è«ççãªããŸãã¯ãã å€ã®1ã€ãtrueã®å Žåãtrueãè¿ããŸãã
console.log(false || true) // â true console.log(false || false) // â false
ãããããã¯æå笊ãïŒãã䜿çšããŠæžãããŠããŸãã ããã¯ãæå®ãããå€ãéã«ããåé æŒç®åã§ãã ïŒtrueã¯false ã! falseã¯trueã§ãã
è«çæŒç®åãšç®è¡æŒç®åã䜿çšããå Žåãæ¬åŒ§ããã€å¿ èŠãã¯å¿ ãããæ確ã§ã¯ãããŸããã å®éã«ã¯ããããç¥ãããšã§ãããåŠçã§ããŸã|| åªå é äœã¯èª°ãããäœãã次ã«&&ã次ã«æ¯èŒæŒç®åããããŠä»ã®å šå¡ãåªå ãããŸãã ãã®é åºã¯ã次ã®ãããªåŒã§ãæ¬åŒ§ãæå°éã«äœ¿çšã§ããããã«éžæãããŸããã
1 + 1 == 2 && 10 * 10 > 50
æåŸã®è«çæŒç®åã¯åé ã§ãäºé ã§ããããŸãã-äžéã§ãã çå笊ãšã³ãã³ã䜿çšããŠèšè¿°ãããŠããŸãã
console.log(true ? 1 : 2); // â 1 console.log(false ? 1 : 2); // â 2
ããã¯ãçå笊ã®å·ŠåŽã®å€ãã³ãã³ã§åºåããã2ã€ã®å€ã®ãããããéžæããæ¡ä»¶æŒç®åã§ãã å·ŠåŽã®å€ãtrueã®å Žåãæåã®å€ãéžæããŸãã falseã®å Žåã2çªç®ã
æªå®çŸ©ã®å€
æå³ã®ããå€ããªãããšã瀺ãããã«äœ¿çšããã2ã€ã®ç¹å¥ãªå€ãnullãšundefinedããããŸãã åç¬ã§ã¯ãæ å ±ãäŒéããŸããã
å€ãè¿ããªãã¹ããŒãã¡ã³ãã®å€ãã¯ãåã«äœããè¿ãããã«undefinedãè¿ããŸãã æªå®çŸ©ãšnullã®éãã¯ãå¶ç¶ã«èšèªã«çŸããéåžžã¯åé¡ã§ã¯ãããŸããã
èªååå€æ
JavaScriptã䜿çšãããšãå Žåã«ãã£ãŠã¯éåžžã«å¥åŠãªããã°ã©ã ãå®è¡ã§ããŸãã äŸïŒ
console.log(8 * null) // â 0 console.log("5" - 1) // â 4 console.log("5" + 1) // â 51 console.log("" * 2) // â NaN console.log(false == 0) // â true
ãééã£ããã¿ã€ãã®å€ã«æŒç®åãé©çšããããšãJavaScriptã¯ãåžžã«æåŸ ãæºãããŠããªãäžé£ã®ã«ãŒã«ã䜿çšããŠãå€ãéãã«ç®çã®ã¿ã€ãã«å€æããŸãã ããã¯åŒ·å¶ãšåŒã°ããŸãã æåã®åŒã§ã¯ãnullã¯0ã«å€ãããã5ãã¯5ã«ãªããŸãïŒæååããæ°å€ãžïŒã ãã ãã3çªç®ã®åŒã§ã¯ã+ã¯æååãé£çµïŒé£çµïŒããŸãããã®ããã1ã¯ã1ãã«å€æãããŸãïŒæ°å€ããæååã«ïŒã
æçœã§ã¯ãªããã®ãæ°å€ã«å€ãããšïŒããšãã°ãã5ããŸãã¯æªå®çŸ©ïŒãå€NaNãè¿ãããŸãã NaNã䜿çšããåŸç¶ã®ç®è¡æŒç®ã¯ãåã³NaNãåãåããŸãã ãã®å€ãååŸããããã©ã³ãã ã¿ã€ãå€æãçºçããå Žæãæ¢ããŸãã
åãã¿ã€ãã®å€ã==ãšæ¯èŒããå Žåãããããåãã§ããå Žåã«çã«ãªãã¹ãã ãšç°¡åã«äºæž¬ã§ããŸãïŒNaNã®å Žåãé€ãïŒã ãã ããã¿ã€ããç°ãªãå ŽåãJavaScriptã¯æ¯èŒã®ããã«è€éã§ãããã«ããäžé£ã®ã«ãŒã«ã䜿çšããŸãã éåžžã圌ã¯äžæ¹ã®æ°éãããäžæ¹ã®æ°éã«ââå€æããããšããŸãã ã¹ããŒãã¡ã³ãã®çåŽã§nullãŸãã¯undefinedãçºçããå Žåãäž¡åŽãnullãŸãã¯undefinedã§ããã°trueãè¿ããŸãã
console.log(null == undefined); // â true console.log(null == 0); // â false
æåŸã®äŸã¯ã䟿å©ãªããªãã¯ã瀺ããŠããŸãã å€ã«nullãŸãã¯undefinedã®ä»£ããã«å®éã®å€ããããã©ããã確èªããå¿ èŠãããå Žåã¯ã==ãŸãã¯ïŒ=ã§nullãšæ¯èŒããã ãã§ãã
ããããäœããæ£ç¢ºãªå€ãšæ¯èŒããå¿ èŠãããå Žåã¯ã©ãã§ããããïŒ åãããŒã«å€ã«å€æããèŠåã§ã¯ã0ãNaNãããã³ç©ºã®æååããã¯åœãšèŠãªãããä»ã®ãã¹ãŠã¯çãšèŠãªãããŸãã ãããã£ãŠã0 == falseããã³ââ == falseã§ãã èªååå€æãå¿ èŠãªãå Žåã¯ãããã«2ã€ã®æŒç®å===ããã³ïŒ==ã䜿çšã§ããŸãã æåã¯2ã€ã®å€ãå®å šã«åäžã§ããããšãæ€èšŒãã2çªç®ã¯2çªç®ã®å€ãå®å šã«åäžã§ããããšãæ€èšŒããŸãã ãããŠãæ¯èŒââ === falseã¯falseãè¿ããŸãã
äºæããªãçµæã«ã€ãªããå¯èœæ§ã®ããäºæããªãåå€æãé²ãããã«ã3æåã®æ¯èŒæŒç®åã䜿çšããããšããå§ãããŸãã æ¯èŒããå€ã®ã¿ã€ããäžèŽããããšã確å®ãªå Žåã¯ãçãæŒç®åãå®å šã«äœ¿çšã§ããŸãã
è«çæŒç®åã®çãèšç®
è«çæŒç®å&&ããã³|| ããŸããŸãªçš®é¡ã®æ°éãéåžžã«å¥åŠãªæ¹æ³ã§åŠçããŸãã 次ã«äœããã¹ãããç解ããããã«ãæŒç®åã®å·ŠåŽã®å€ãããŒã«å€ã«å€æããŸãããæŒç®åãšãã®å€æã®çµæã«å¿ããŠãå·ŠåŽãŸãã¯å³åŽããå ã®å€ãè¿ããŸãã
ããšãã°ã|| trueã«å€æã§ããå Žåãå·ŠåŽã®å€ãè¿ããŸãããã以å€ã®å Žåãå³åŽãè¿ããŸãã
console.log(null || "user") // â user console.log("Karl" || "user") // â Karl
ãã®ãããªæŒç®å|| ããã©ã«ãå€ãžã®ããŒã«ããã¯ãšããŠäœ¿çšã§ããŸãã å·ŠåŽã«ç©ºã®å€ãè¿ãããšãã§ããåŒãæå®ãããšãå³åŽã®å€ããã®ã±ãŒã¹ã®ä»£æ¿ãšããŠæ©èœããŸãã
&&æŒç®åã¯åæ§ã«æ©èœããŸãããéãåæ§ã§ãã å·ŠåŽã®å€ãfalseã«å€æããããšããã®å€ãè¿ãããããã§ãªãå Žåã¯å³åŽã®å€ãè¿ãããŸãã
ãã1ã€ã®éèŠãªç¹æ§ã¯ãå³åŽã®åŒãå¿ èŠãªå Žåã«ã®ã¿èšç®ãããããšã§ãã çã®å Žå|| Xãäœã«çãããã¯é¢ä¿ãããŸãããããããäœããã®ã²ã©ãè¡šçŸã§ãã£ãŠãã çµæã¯åžžã«çã§ãããXã¯èšç®ãããŸããã False && Xãæ©èœããŸã-Xã¯åã«ç¡èŠãããŸãã ããã¯ã·ã§ãŒãèšç®ãšåŒã°ããŸãã
æ¡ä»¶ã¹ããŒãã¡ã³ããåãããã«æ©èœããŸãã æåã®åŒã¯åžžã«èšç®ããã2çªç®ãš3çªç®ã®å€ãã-çµæãšããŠéžæãããåŒã®ã¿ãèšç®ãããŸãã
ãŸãšã
æ°å€ãæååãããŒã«å€ãæªå®çŸ©ã®4çš®é¡ã®JavaScriptå€ãèŠãŸããã
ãããã®å€ã¯ãååïŒtrueãnullïŒãŸãã¯å€ïŒ13ããeprstãïŒãèšè¿°ãããšãã«ååŸãããŸãã ãããã¯ãæŒç®åã䜿çšããŠçµåããã³å€æŽã§ããŸãã ç®è¡æŒç®ã«ã¯ã2é æŒç®åïŒ+ã-ã*ã/ãããã³ïŒ ïŒãæååé£çµïŒ+ïŒãæ¯èŒïŒ== ã! =ã=== ã! ==ã<ã>ã<=ã> =ïŒããããŸããããã³è«çæŒç®åïŒ&&ã||ïŒãããã³ããã€ãã®åé æŒç®åïŒè² ã®å€ã®å Žåã¯-ãè«çåŠå®ã®å Žåã¯ïŒãæ°éã®ã¿ã€ãã決å®ããå Žåã¯typeofïŒã
ãã®ç¥èã«ãããJavaScriptãèšç®æ©ãšããŠäœ¿çšã§ããŸããããã以äžã¯äœ¿çšã§ããŸããã 次ã®ç« ã§ã¯ããããã®åçŽãªæå³ãçµã³ä»ããŠåçŽãªããã°ã©ã ãäœæããŸãã