JavaScript(ES2015ïŒES6ïŒ) ãProgateððJavaScriptâ ¥ïŒé åãæäœããã¡ãœãããåŠãŒãïŒã
ãåºå€§ãªå±±ã ãšæã£ãŠããJavaScriptã®åŠç¿ãã©ã³ãçµç€ã«ãªããã¿ãªããäžå®ãããããŸãGAïŒããšããããç»ããã£ãŠãå±±ã®å
šè²ã確èªããããšæããŸãããã£ãšãç»ãåã£ããã®å
ã«ã¯âŠ ã©ã¹ãã¹ãåŸ
ã£ãŠããããºâŠâ
ããã®ç« ã§ã¯ãJavaScriptãå®è·µçã«äœ¿ãéã«å¿
é ã®ãé
åãæäœããã¡ãœããã«ã€ããŠåŠãã§ãããŸããïŒProgateæ§ïŒ
ðpushã¡ãœãã
ðforEachã¡ãœãã
ðfindã¡ãœãã
ðfilterã¡ãœãã
ðmapã¡ãœãã
ãðpushã¡ãœããã
ðžé
åã®æåŸã«æ°ããèŠçŽ ãè¿œå ããã¡ãœãã
ãðforEachã¡ãœããã
ðžé
åã®äžã®èŠçŽ ã1ã€ãã€åãåºããŠãå
šãŠã®èŠçŽ ã«åãç¹°ãè¿ãåŠçãè¡ãã¡ãœãã
ãâã¢ããŒé¢æ°å
ã®ãåŒæ°ãããåŠçãã®å€ã¯ã©ããã⊠ðâ ïžïŒïŒ
ãâã¢ããŒé¢æ°ã®æ¬é çºæ®ïŒ
ããïŒð¥ã³ãŒã«ããã¯é¢æ°ð¥
ããâ ïžé
åå
ã®èŠçŽ ãäžã€ãã€é çªã«ã¢ããŒé¢æ°ã®åŒæ°ã«ä»£å
¥ãããåŠçãç¹°ãè¿ãç¹°ãè¿ãå®è¡ããããïŒããŒããŒå³è§£åã奜ããâïžïŒ
ãâæ¬åœã¯ãã£ãšé£è§£ã§è€éãªå 容ãååŒããŠæ¶åããããããã«ããŠããããåºæ¬åŠç¿ã®ç¥ã§ããâŠâšð§ðš
ãðfindã¡ãœããã
ðžã³ãŒã«ããã¯é¢æ°ã®åŠçéšåã«èšè¿°ããæ¡ä»¶åŒã«åãé
åã®èŠçŽ ããé
åã®äžããåãåºãã¡ãœãã
ãâæ¡ä»¶ã«åãèŠçŽ ãèŠã€ãã£ãæã«åŠçãçµäºãã
ããïŒæ¡ä»¶ã«åãæåã®èŠçŽ ããåãåºããªãïŒ
ðžé
åèŠçŽ ããªããžã§ã¯ãã®éã䜿çšã§ãã
ãâãªããžã§ã¯ãã®ããããã£ãæ¡ä»¶ãšããŠäœ¿çšããå Žåããã®ããããã£ããã€ãªããžã§ã¯ããã®ãã®ãåãåºãðâš
ãââ ïžreturn character.id === 3;ãâã ===ãã«ããŠãªãã£ãð±
ãðfilterã¡ãœããã
ðžèšè¿°ããæ¡ä»¶ã«åãèŠçŽ ã®ã¿ãåãåºããŠæ°ããé
åãäœæããã¡ãœãã
ãâðfindã¯ãæ¡ä»¶ã«åãèŠçŽ ãèŠã€ãã£ãæã«åŠçãçµäºãã
ãâfindã®ãå
ã¡ãããfilterãªã€ã¡ãŒãžïŒð£ïŒð¥ïŒ
ãðmapã¡ãœããã
ðžé
åå
ã®å
šãŠã®èŠçŽ ã«åŠçãè¡ãããã®æ»ãå€ããæ°ããé
åãäœæããã¡ãœãããâ ããæ匷âΣïŒã»â¡ã»ïŒïŒ
ãâäžèŠè€éã«èŠãããã©ããããŸã§ã®åºç€åŠç¿ãããŒã¹ãäžã€äžã€éãªã£ãŠäœããããããŠããæããããŸããâïž
ãâ倧æåã®å€æããã£ããå¿ããŠããŸããä»æ¥ãã®é âŠ
ããŸãšãã
ä»åã现ã
åŠç¿ã§ããããçŽ1ïœçšã§ä¿®äºããŸããâïžðãŸããå®æŠã§äœ¿ãããªããçšã®ç¿åŸçãã¯ããŠãããããããJavaScriptæåŸã®åŠç¿ããŒãžã«å
¥ããŸãÙ©( 'Ï' )ÙâªïŒä»åã¯ãã§ãã¯æžã¿ïŒåŠç¿åŸã«ã¯ãã¥ãŒããªã¢ã«ã®èšäºã2ã€æâïžïŒ
ãã®èšäºãæ°ã«å ¥ã£ãããµããŒããããŠã¿ãŸãããïŒ