ç°å¢ãšç®æšã®ç¹æ®æ§ã«ãããJavaScriptã¯éåžžã®ããã°ã©ãã³ã°èšèªãšã¯ç°ãªããå€ãã®æ©èœãåããŠããŸãããåªããã¯ãã¹ãã©ãŠã¶ãŒã³ãŒããäœæããããšã¯éåžžã«å°é£ã§ãã
JavaScriptã³ãŒããæ°æ¥ä»¥äžæžããããã°ã©ããŒã®ã»ãšãã©ã¯ããããã®æ©èœã«åºãããããšæããŸãã ãã®ãããã¯ã®ç®çã¯ãæ°ããäœããçºèŠããããšã§ã¯ãªãããããã®æ©èœããæã§ã ãæ¬ ç¹ãã§èª¬æããŠãå©ç¹ããäœæããããšã§ãã
ãã®ãããã¯ã§ã¯ä»¥äžãæ€èšããŸãã
- ç絡
- ãããã¿ã€ãã³ã°
- å®è¡ã³ã³ããã¹ã
ãŸããã
ãã¡ãããèè ãšããŠãJavaScriptã®è±å¯ãªå¯èœæ§ããã¹ãŠèª¬æããããšæããŸãã ããããç§ããããããããšãããšãèšäºã¯èšå€§ãªæ°ã®ããŒãžã«ãŸããããå€ãã®åå¿è éçºè ã¯ãã¹ãŠã®æ å ±ãæãåºããªããªããŸãã ãããã£ãŠãåŒçšãããŠããäŸã¯åçŽãããããã«æããããããã¯ã¯å®å šã«ã¯é瀺ãããŠããŸããã ãããããããã®æ©èœã«ãŸã æ £ããŠããªã人ãããã§ã«æ £ããŠãã人ããå®éã«ã¯ãã¹ãŠãåæ©çã§ããããšãç解ããã®ã«åœ¹ç«ã€ããšãé¡ã£ãŠããŸãã
ééããŸãã¯ããããã®ç°åžžãªç¯å²ã
ã䟿å©ãªãã®ïŒã-ããã2ã€ã®èšèã¯è¡šçŸã§ããŸã
JavaScriptã§ã®ã¯ããŒãžã£ãšãã®å®è£ ã«å¯Ÿããç§ã®å§¿å¢ã
ã¯ããŒãžã£ãŒã®æ¬è³ªã¯ç°¡åã§ãã é¢æ°å ã§ã¯ãé¢æ°ã宣èšãããå Žæã§å©çšå¯èœãªãã¹ãŠã®å€æ°ã䜿çšã§ããŸã ã
ã¯ããŒãžã£ã®æŠå¿µã¯åçŽã§ãããå®éã«ã¯ãç¹å®ã®å Žåã®åäœã«ã€ããŠå€ãã®ãããŸããªç¹ããããŸãã æåã«ãå€æ°ã®å®£èšã®åºæ¬ãã€ãŸãã JavaScriptã®å€æ°ã¯varããŒã¯ãŒãã䜿çšããŠå®£èšããã ããæãåºããŸãããã
var title = "Hello World"; alert(title);
ã³ãŒããå®è¡ãããšãæåŸ ã©ããã«ã Hello World ããšããããã¹ãã衚瀺ãããŸãã äœãèµ·ãã£ãŠãããã®æ¬è³ªã¯åçŽã§ã-ã°ããŒãã«å€æ°ã®ã¿ã€ãã«ãå€ã Hello World ãã§äœæãããããã¯alertã䜿çšããŠãŠãŒã¶ãŒã«è¡šç€ºãããŸãã ãã®äŸã§ã¯ã varããŒã¯ãŒããçç¥ããŠããã°ããŒãã«ã³ã³ããã¹ãã®ããã«ã³ãŒãã¯æ£åžžã«æ©èœããŸãã ããããããã«ã€ããŠã¯åŸã§ã
次ã«ãåãå€æ°ã宣èšããããšããŸããããã§ã«é¢æ°å ã«ãããŸãã
function example (){ var title = "Hello World"; } alert(title);
ã³ãŒããå®è¡ããçµæãã 'title' is undefined ã-ã å€æ° 'title'ã宣èšãããŠããŸãã ããšãããšã©ãŒãçæãããŸãã ããã¯ãå€æ°ã®ããŒã«ã«ã¹ã³ãŒãã®ã¡ã«ããºã ã«ãããã®ã§ãã é¢æ°å ã§å®£èšããããã¹ãŠã®å€æ°ã¯ããŒã«ã«ã§ããããã®é¢æ°å ã§ã®ã¿è¡šç€ºãããŸã ã ãŸãã¯ãåçŽã«ïŒé¢æ°å ã§å€æ°ã宣èšããå Žåããã®é¢æ°ã®å€éšã§ã¯ãã®å€æ°ã«ã¢ã¯ã»ã¹ã§ããŸããã
ç¢æã Hello World ãã衚瀺ããã«ã¯ãåŒã³åºãããé¢æ°å ã§ã¢ã©ãŒããåŒã³åºãå¿ èŠããããŸãã
function example(){ var title = "Hello World"; alert(title); } example();
ãŸãã¯ãé¢æ°ããå€ãè¿ããŸãã
function example(){ var title = "Hello World"; return title; } alert(example());
ãããã®äŸã¯ãã¹ãŠæçœã ãšæããŸã-ãã®ãããªåäœã¯ãã»ãŒãã¹ãŠã®ããã°ã©ãã³ã°èšèªã§å®è£ ãããŠããŸãã ããã§ã¯ãå®è£ ãä»ã®èšèªãšéåžžã«ç°ãªããã®ã«ããJavaScriptã®ã¯ããŒãžã£ãŒã®ç¹æ§ã¯äœã§ããïŒ
äž»ãªéãã¯ãJavaScriptã§ã¯é¢æ°ãä»ã®é¢æ°å ã§å®£èšã§ããJavaScriptã®é¢æ°ã¯ãªããžã§ã¯ãã§ãããšããããšã§ãïŒ ããã«ãããéåžžã®ãªããžã§ã¯ããšåãã¢ã¯ã·ã§ã³ãå®è¡ã§ããŸã-ååšã®ç¢ºèªãå€æ°ãžã®å²ãåœãŠãããããã£ã®è¿œå ãã¡ãœããã®åŒã³åºããå¥ã®é¢æ°ã®çµæãšããŠé¢æ°ãªããžã§ã¯ããè¿ãïŒ
é¢æ°ã¯ãªããžã§ã¯ãã§ãããããå€æ°ã®ã¹ã³ãŒãã¯é¢æ°ã«ãé©çšãããããšãæå³ããŸããå¥ã®é¢æ°å ã§å®£èšãããé¢æ°ã¯ã宣èšãããå Žæã§ã®ã¿è¡šç€ºãããŸã
function A(){ function B(){ alert("Hello World"); } } B();
å€æ°ã䜿çšããäŸã®ããã«ãã³ãŒããå®è¡ãããšãå€æ°Bã宣èšãããŠããªããšãããšã©ãŒãçæãããŸãã é¢æ°Aå ã®å®£èšã®çŽåŸã«é¢æ°BãåŒã³åºããé¢æ°AèªäœãåŒã³åºããšã倧äºãªã¡ãã»ãŒãžã Hello World ãã衚瀺ãããŸã
function A(){ function B(){ alert("Hello World"); } B(); } A();
ããã§ã¯ãã»ãšãã©ã®åå¿è ãJavaScriptã«ã€ããŠäœãåŠã¶ãã«ã€ããŠèª¬æãå§ããŸããããå€æ°ãã©ãããæ¥ãã®ããå€æããŸãã äžèšã®ããã«ãå€æ°ã¯varããŒã¯ãŒãã䜿çšããŠå®£èšããå¿ èŠããããŸãã
var title = 'external'; function example(){ var title = 'internal'; alert(title); } example(); alert(title);
ãã®äŸã§ã¯ã ã¿ã€ãã«å€æ°ã2å宣èšãããŠããŸãã1åç®ã¯ã°ããŒãã«ã«ã2åç®ã¯é¢æ°å ã§ã ãµã³ãã«é¢æ°å ã§ã¯ã varããŒã¯ãŒãã䜿çšããŠã¿ã€ãã«å€æ°ã宣èšããããããããŒã«ã«ã«ãªããé¢æ°ã®åã«å®£èšãããã¿ã€ãã«å€æ°ãšã¯é¢ä¿ãããŸããã ã³ãŒãå®è¡ã®çµæãæåã«ã å éš ãïŒå éšå€æ°ïŒã衚瀺ããã次ã«ã å€éš ãïŒã°ããŒãã«å€æ°ïŒã衚瀺ãããŸãã
æååvar title = 'internal'ããvarããŒã¯ãŒããåé€ãããšãã³ãŒããå®è¡ããçµæãã¡ãã»ãŒãž " internal "ã2åååŸãããŸãã ããã¯ãé¢æ°ãåŒã³åºãããšãã«ãããŒã«ã«å€æ°titleã宣èšããªãã£ãããã°ããŒãã«å€æ°ã®å€ãäžæžãããããã§ãïŒ
ãããã£ãŠãvarããŒã¯ãŒãã䜿çšãããšå€æ°ãããŒã«ã«ã«ãªããå€éšå€æ°ãšç«¶åããªãããšãä¿èšŒãããŸãïŒ ããšãã°ãPHPã§ã¯ãé¢æ°å ã®ãã¹ãŠã®å€æ°ã¯ããã©ã«ãã§ããŒã«ã«ã§ããã°ããŒãã«å€æ°ã«ã¢ã¯ã»ã¹ããã«ã¯ãã°ããŒãã«å€æ°ã䜿çšããŠå®£èšããå¿ èŠããããŸãããŒã¯ãŒãglobal ïŒã
é衚瀺ã®ããã¹ã
é¢æ°ã®ãã¹ãŠã®ãã©ã¡ãŒã¿ãŒã¯èªåçã«ããŒã«ã«å€æ°ã§ããããšã«æ³šæããŠãã ããïŒ
ã³ãŒããå®è¡ããããšãã change external title ããšããã¡ãã»ãŒãžãçæããã次ã«ã external title ããšããã¡ãã»ãŒãžãçæãããŸããããã¯ãå€éšå€æ°titleãé¢æ°å ã§å€æŽãããªãã£ãããšã瀺ããŸãã
ããŒã«ã«å€æ°ãåæåããããã»ã¹ã¯ãã³ãŒããå®è¡ãããåã«çºçããŸã-ãã®ãããã€ã³ã¿ãŒããªã¿ãŒã¯é¢æ°ã³ãŒããå®è¡ããŠåæåããŸãïŒ å€ãå²ãåœãŠãã«ïŒ ïŒèŠã€ãã£ããã¹ãŠã®ããŒã«ã«å€æ°ïŒ
åã®äŸã®ããã«ãã³ãŒããå®è¡ãããšãã å€éšã¿ã€ãã«ãå€æŽããŠããŸãããšããã¡ãã»ãŒãžãçæããã次ã«ã å€éšã¿ã€ãã« ããçæãããŸããããã¯ãå€éšå€æ°ã®ã¿ã€ãã«ãé¢æ°å ã§å€æŽãããŠããªãããšã瀺ããŸãã
è¡ã¿ã€ãã«=ãå€éšã¿ã€ãã«ã®å€æŽããã³ã¡ã³ãã¢ãŠãããå Žå; ããã®åŸãçæãããæåã®ã¡ãã»ãŒãžã¯ã æªå®çŸ© ãã«ãªããŸã-ããŒã«ã«å€æ°ã®ã¿ã€ãã« ã¯ãã§ã«åæåãããŠããŸãïŒååšããŸãïŒããå€ïŒã¢ã©ãŒããåŒã³åºããããšãïŒã¯å²ãåœãŠãããŠããŸããã
ã³ãŒãïŒ
以äžãšåçïŒ
ãããã£ãŠãå€æ°ãé¢æ°å ã§ã©ãã§å®£èšãããŠããŠããå€æ°ã¯åŒã³åºãæã«åæåãããããšãæããã«ãªããŸãã ãŸããå宣èšã¯æå³ããªããªãããšãæå³ããŸã-ã€ã³ã¿ãŒããªã¿ãŒã¯ãå€æ°å®£èšã2ååã«ç¡èŠããŸãã
var title = "external title"; function example(title){ title = "changing external title"; alert(title); } example('abc'); alert(title);
ã³ãŒããå®è¡ããããšãã change external title ããšããã¡ãã»ãŒãžãçæããã次ã«ã external title ããšããã¡ãã»ãŒãžãçæãããŸããããã¯ãå€éšå€æ°titleãé¢æ°å ã§å€æŽãããªãã£ãããšã瀺ããŸãã
ããŒã«ã«å€æ°ãåæåããããã»ã¹ã¯ãã³ãŒããå®è¡ãããåã«çºçããŸã-ãã®ãããã€ã³ã¿ãŒããªã¿ãŒã¯é¢æ°ã³ãŒããå®è¡ããŠåæåããŸãïŒ å€ãå²ãåœãŠãã«ïŒ ïŒèŠã€ãã£ããã¹ãŠã®ããŒã«ã«å€æ°ïŒ
var title = "external title"; function example(){ title = "changing external title"; alert(title); var title = "internal title"; } example(); alert(title);
åã®äŸã®ããã«ãã³ãŒããå®è¡ãããšãã å€éšã¿ã€ãã«ãå€æŽããŠããŸãããšããã¡ãã»ãŒãžãçæããã次ã«ã å€éšã¿ã€ãã« ããçæãããŸããããã¯ãå€éšå€æ°ã®ã¿ã€ãã«ãé¢æ°å ã§å€æŽãããŠããªãããšã瀺ããŸãã
è¡ã¿ã€ãã«=ãå€éšã¿ã€ãã«ã®å€æŽããã³ã¡ã³ãã¢ãŠãããå Žå; ããã®åŸãçæãããæåã®ã¡ãã»ãŒãžã¯ã æªå®çŸ© ãã«ãªããŸã-ããŒã«ã«å€æ°ã®ã¿ã€ãã« ã¯ãã§ã«åæåãããŠããŸãïŒååšããŸãïŒããå€ïŒã¢ã©ãŒããåŒã³åºããããšãïŒã¯å²ãåœãŠãããŠããŸããã
ã³ãŒãïŒ
function example(){ alert(title); var title = "internal title"; }
以äžãšåçïŒ
function example(){ var title; alert(title); title = "internal title"; }
ãããã£ãŠãå€æ°ãé¢æ°å ã§ã©ãã§å®£èšãããŠããŠããå€æ°ã¯åŒã³åºãæã«åæåãããããšãæããã«ãªããŸãã ãŸããå宣èšã¯æå³ããªããªãããšãæå³ããŸã-ã€ã³ã¿ãŒããªã¿ãŒã¯ãå€æ°å®£èšã2ååã«ç¡èŠããŸãã
ããã§ã¯ãã©ã®å€æ°ãé¢æ°ã§äœ¿çšãããŠããããã©ã®ããã«å€æããŸããïŒ
é¢æ°ã宣èšãããšãã«ãå€æ°ãvarããŒã¯ãŒãã䜿çšããŠããŒã«ã«ã«å®£èšãããŠããªãå Žåãå€æ°ã¯èŠªé¢æ°ã§æ€çŽ¢ãããŸãã ããã§èŠã€ãããªãå Žåãã€ã³ã¿ãŒããªã¿ãŒãå€æ°å®£èšãèŠã€ããããã°ããŒãã«ã¹ã³ãŒãã«å°éãããŸã§ã芪é¢æ°ã®ãã§ãŒã³ãæ€çŽ¢ãç¶ããŸãã
é¢æ°å®£èšã®ãã§ãŒã³äžãŸãã¯ã°ããŒãã«ã¹ã³ãŒãå ã§å€æ°å®£èšãèŠã€ãããªãå Žåã2ã€ã®éçºãªãã·ã§ã³ããããŸãã
- å€æ°ã䜿çšïŒå€ãååŸïŒããããšãããšãå€æ°ã宣èšãããŠããªããšãããšã©ãŒãçæãããŸã
- å€æ°ã«å€ãå²ãåœãŠãããšãããšãå€æ°ãã°ããŒãã«ã¹ã³ãŒãã§äœæãããå€ãå²ãåœãŠãããŸãã
function A(){ title = 'internal'; return function B(){ alert(title); } } var B = A(); B(); alert(title);
ã³ãŒããå®è¡ããåŸãäž¡æ¹ã®æéã å éš ããååŸããŸãã é¢æ°Aå ã®ã¿ã€ãã«å€æ°ã«å€ãå²ãåœãŠããšãé¢æ°å€ã§äœ¿çšã§ããã°ããŒãã«å€æ°ãäœæãããŸãã å€æ°ãžã®å€ã®å²ãåœãŠïŒãããã£ãŠã°ããŒãã«å€æ°ã®äœæïŒã¯é¢æ°AãåŒã³åºã段éã§çºçãããããé¢æ°AãåŒã³åºãåã«ã¢ã©ãŒãïŒã¿ã€ãã«ïŒãåŒã³åºãããšãããšãšã©ãŒãçæãããããšã«æ³šæããŠãã ããã
é衚瀺ã®ããã¹ã
å®éãã°ããŒãã«å€æ°ã®ã¡ã«ããºã ã¯ããã§èª¬æãããããå°ãè€éã§ãïŒåæåãããŠããªãå€æ°ã«å€ãå²ãåœãŠãããšãããšãã°ããŒãã«å€æ°ã¯äœæãããŸãããããŠã£ã³ããŠãªããžã§ã¯ãã®ããããã£ïŒ ãã¹ãŠã®ã°ããŒãã«å€æ°ã®ã³ã³ãããšããŠæ©èœããŸã ïŒã
ã°ããŒãã«å€æ°ïŒ varã§å®£èš ïŒãšã®äž»ãªéãã¯ã deleteæŒç®åã䜿çšããŠå€æ°ãåé€ã§ããªãããšã§ãã ãã以å€ã®å ŽåããŠã£ã³ããŠãªããžã§ã¯ãã®ããããã£ã®æäœã¯ãã°ããŒãã«å€æ°ã®æäœãšåãã§ãã
詳现ã¯ãã¡ã ã
ã°ããŒãã«å€æ°ïŒ varã§å®£èš ïŒãšã®äž»ãªéãã¯ã deleteæŒç®åã䜿çšããŠå€æ°ãåé€ã§ããªãããšã§ãã ãã以å€ã®å ŽåããŠã£ã³ããŠãªããžã§ã¯ãã®ããããã£ã®æäœã¯ãã°ããŒãã«å€æ°ã®æäœãšåãã§ãã
詳现ã¯ãã¡ã ã
JavaScriptã®ã¯ããŒãžã£ãŒã®ãããã¯ã«æ»ããŸãã
JavaScriptã¯ãä»ã®ã»ãšãã©ã®ããã°ã©ãã³ã°èšèªãšæ¯èŒããŠãå€æ°ã¹ã³ãŒãã䜿çšããããæè»ãªã¢ãããŒããæäŸããŸãã ãŸããããŒã«ã«ã¹ã³ãŒããšä»ã®é¢æ°å ã®é¢æ°ã®åçãªå®£èšãçµã¿åãããå¯èœæ§ããããããã¯ããŒãžã£ãŒã¡ã«ããºã ãçºçããŸãã
ãåç¥ã®ããã«ããã¹ãŠã®ããŒã«ã«å€æ°ã¯æ°ããé¢æ°åŒã³åºãããšã«åäœæãããŸãã ããšãã°ãé¢æ°Aããã ããã®äžã§å€æ°titleã宣èšãããŠããŸãã
function A(){ var title = 'internal'; alert(title); } A();
é¢æ°Aãå®è¡ããããšãå€æ°titleã¯ååšããªããªããã¢ã¯ã»ã¹ã§ããªããªããŸãã äœããã®æ¹æ³ã§å€æ°ã«ã¢ã¯ã»ã¹ããããšãããšãå€æ°ã宣èšãããŠããªããšãããšã©ãŒãçºçããŸãã
ããã§ãé¢æ°Aã®äžã«ã titleå€æ°ã®å€ã衚瀺ããé¢æ°å®£èšãšããã®å€ãæž¡ãããå€ã«å€æŽããé¢æ°ãè¿œå ãããããã®é¢æ°ãè¿ããŸãã
function getTitle (){ var title = "default title"; var showTitle = function(){ alert(title); }; var setTitle = function(newTitle){ title = newTitle; }; return { "showTitle": showTitle, "setTitle": setTitle }; } var t = getTitle(); t.showTitle(); t.setTitle("Hello World"); t.showTitle();
ãã®äŸãéå§ããåã«ã ã¿ã€ãã«å€æ°ã®åäœãè«ççã«èª¿ã¹ãŠã¿ãŸããgetTitleé¢æ°ãèµ·åããããšãå€æ°ãäœæãããåŒã³åºããå®äºãããšç Žæ£ãããŸãã ãã ãã getTitleé¢æ°ãåŒã³åºããããš ããã®å€æ°ã䜿çšãã2ã€ã®åçã«å®£èšãããshowTitleããã³setTitleé¢æ°ãæã€ãªããžã§ã¯ããè¿ãããŸãã ãããã®é¢æ°ãåŒã³åºããšã©ããªããŸããïŒ
ãããŠããã®äŸãå®è¡ãããšãæåã«ã ããã©ã«ãã®ã¿ã€ãã« ãã衚瀺ããã次ã«ã Hello World ãã衚瀺ãããããšãããããŸã ã ãããã£ãŠã ã¿ã€ãã«å€æ°ã¯ååšãç¶ããŸããã getTitleé¢æ°ã¯æ¢ã«çµäºããŠããŸãã ãã ããäžèšã®showTitle / setTitleé¢æ°ãé€ãããã®å€æ°ã«ã¯ä»ã«ã¢ã¯ã»ã¹ã§ããŸããã ããã¯ã¯ããŒãžã£ãŒã®ç°¡åãªäŸã§ãã ã¿ã€ãã«å€æ°ã¯ãã¯ããŒãºãããã宣èšäžã«ã¢ã¯ã»ã¹ã§ããé¢æ°ã®ã¿ã«è¡šç€ºãããŸãã
getTitleé¢æ°ãå床å®è¡ãããšã ã¿ã€ãã«å€æ°ãšshowTitle / setTitleé¢æ°ãæ¯ååäœæããã以åã®å®è¡ãšã¯é¢ä¿ããªãããšãããããŸãã
var t1 = getTitle(); t1.setTitle("Hello World 1"); var t2 = getTitle(); t2.setTitle("Hello World 2"); t1.showTitle(); t2.showTitle();
ã³ãŒããå®è¡ãããšïŒäžèšã®getTitleé¢æ°ã³ãŒããè¿œå ããããšãå¿ããã«ïŒãã Hello World 1 ããšã Hello World 2 ããšãã2ã€ã®ã¡ãã»ãŒãžãçæãããŸãïŒ ãã®åäœã¯ãã©ã€ããŒãå€æ°ããšãã¥ã¬ãŒãããããã«äœ¿çšãããŸã ïŒã
çè«ãšæãåçŽãªäŸãæ®ããŠãå®éã«ã¯ããŒãžã£ããã©ã®ãããªå©çãåŸãããããç解ããããšããŸãã
1ã€ã¯ãã°ããŒãã«ã¹ã³ãŒããè©°ãŸãããªãæ©èœã§ãã
ã°ããŒãã«ã¹ã³ãŒãã§ã®ç«¶åã®åé¡ã¯æããã§ãã ç°¡åãªäŸïŒ showTitleé¢æ°ã宣èšããè€æ°ã®javascriptãã¡ã€ã«ãããŒãžã«æ¥ç¶ãããŠããå Žåã showTitleãåŒã³åºããããšãæåŸã«å®£èšãããé¢æ°ãå®è¡ãããŸãã åãããšã宣èšãããå€æ°ã«ãåœãŠã¯ãŸããŸãã
ãã®ç¶æ³ãåé¿ããã«ã¯ãåé¢æ°/å€æ°ãäžæã®ååã§åŒã³åºãããã¯ããŒãžã£ãŒã䜿çšããå¿ èŠããããŸãã åé¢æ°ãšå€æ°ãäžæã®ååã§å€åœ¢ããŠååãä»ããã®ã¯äžäŸ¿ã§ãããå®å šãªäžææ§ãä¿èšŒãããã®ã§ã¯ãããŸããã äžæ¹ãã¯ããŒãžã£ãŒã¡ã«ããºã ã¯ãå€æ°ãšé¢æ°ã®åœåã«å®å šãªèªç±ãæäŸããŸãã ãããè¡ãã«ã¯ã宣èšã®çŽåŸã«å®è¡ãããå¿åé¢æ°ã§ã³ãŒãå šäœãã©ããããã ãã§ååã§ãã
(function(){ /* , */ })();
ãã®çµæã宣èšããããã¹ãŠã®å€æ°ãšé¢æ°ã¯ã°ããŒãã«ã¹ã³ãŒãã§äœ¿çšã§ããªããªããŸããã€ãŸãã競åã¯çºçããŸããã
ããã§ã1ã€ãŸãã¯2ã€ã®æ©èœã«ã°ããŒãã«ã«ã¢ã¯ã»ã¹ã§ããããšãå¿ èŠãªå Žåã¯ã©ãããã°ããã§ããïŒ ãããŠãããã§ã¯ãã¹ãŠããšãŠãç°¡åã§ãã ã°ããŒãã«ã¹ã³ãŒããæäŸããæãã°ããŒãã«ãªãªããžã§ã¯ãã¯ã ãŠã£ã³ããŠãªããžã§ã¯ãã§ãã é¢æ°ã¯ãªããžã§ã¯ãã§ãããšããäºå®ã«ãããé¢æ°ããŠã£ã³ããŠããããã£ã«å²ãåœãŠãŠãã°ããŒãã«ã«ãªãããšãã§ããŸãã ãã©ã€ããŒãã¹ã³ãŒãããã°ããŒãã«é¢æ°ã宣èšããäŸïŒ
(function(){ var title = "Hello World"; function showTitle(){ alert(title); } window.showSimpleTitle = showTitle; })(); showSimpleTitle();
ã³ãŒãå®è¡ã®çµæãã¡ãã»ãŒãžã Hello World ããçæãããŸã-ããŒã«ã«ã®showTitleé¢æ°ã¯ showSimpleTitleãšããååã§ã°ããŒãã«ã«äœ¿çšå¯èœã«ãªããå¿åé¢æ°ã®å€éšã§ã¯ã¢ã¯ã»ã¹ã§ããªããclosedãå€æ°titleã䜿çšããŸãã
ãªããªã ããã«å®è¡ãããå¿åé¢æ°ã§ãã¹ãŠãã©ãããããšããã®é¢æ°ã«ãã©ã¡ãŒã¿ãŒãæž¡ãããšãã§ããŸãããã®é¢æ°å ã§ã¯ãããŒã«ã«åã§äœ¿çšã§ããŸãã JQueryã®äŸïŒ
(function(){ $('.hidden').hide(); })();
ã°ããŒãã«å€æ°$ãjQueryã§ãªãå Žåããšã©ãŒãã¹ããŒãããŸãã ããã¯ãjQueryã«å ããŠã$é¢æ°ã䜿çšããå¥ã®ã©ã€ãã©ãªïŒPrototype.JSãªã©ïŒã䜿çšãããŠããå Žåã«çºçããŸãã ãé¡ãã®è§£æ±ºçïŒ
(function(){ var $ = jQuery; $('.hidden').hide(); })();
åäœããæ£ããåäœããŸãã ããããããŸããããã§ã¯ãããŸããã ããããããªè§£æ±ºçããããŸã-ããŒã«ã«å€æ°$ãé¢æ°ãžã®åŒæ°ãšããŠå®£èšããããã«jQueryãªããžã§ã¯ããæž¡ããŸãïŒ
(function($){ /* , $ */ })(jQuery);
é¢æ°ã®ãã¹ãŠã®åŒæ°ãããã©ã«ãã§ããŒã«ã«å€æ°ã§ããããšãæãåºããšãå¿åé¢æ°$ã®å éšã§ã¯jQueryãªããžã§ã¯ããžã®åç §ã§ããã°ããŒãã«ãªããžã§ã¯ã$ã«æ¥ç¶ãããŠããªãããšãæããã«ãªããŸãã å¿åé¢æ°ã«ããåä¿¡ãããç解ããããããããã«ãå¿åé¢æ°ãéå¿åã«ããããšãã§ããŸã-é¢æ°ã宣èšããŠããã«èµ·åããŸãïŒ
function __run($){ /* code */ } __run(jQuery);
ããã§ããã°ããŒãã«é¢æ°$ãåŒã³åºãå¿ èŠãããå Žåã¯ã windowã䜿çšã§ããŸãã
2ã€ç®ã¯ãã¯ããŒãžã£ãŒã䜿çšããé¢æ°ã®åçãªå®£èšã§ãã
ã€ãã³ãã¢ãã«ã䜿çšããå Žåãåãã€ãã³ããç°ãªãèŠçŽ ã§ãã³ã°ã¢ããããå¿ èŠãããå Žåã«ããçºçããŸãã ããšãã°ã10åã®divèŠçŽ ããããã¯ãªãã¯ãããšalertïŒNïŒãåŒã³åºãå¿ èŠããããŸãïŒ Nã¯äžæã®èŠçŽ çªå·ã§ãïŒã
ã¯ããŒãžã£ãŒã䜿çšããæãç°¡åãªãœãªã¥ãŒã·ã§ã³ïŒ
for(var counter=1; counter <=10; counter++){ $('<div>').css({ "border": "solid 1px blue", "height": "50px", "margin": "10px", "text-align": "center", "width": "100px" }).html('<h1>'+ counter +'</h1>') .appendTo('body') .click(function(){ alert(counter); }); }
ãã ãããã®ã³ãŒããå®è¡ãããšãäºæããªããçµæãçºçããŸãããã¹ãŠã®ã¯ãªãã¯ã§åãæ°ã衚瀺ãããŸã-11ã
çãã¯ç°¡åã§ãã ã«ãŠã³ã¿ãŒå€æ°ã®å€ã¯ãèŠçŽ ãã¯ãªãã¯ãããšãã«ååŸãããŸãã ãããŠããã®æãŸã§ã«å€æ°ã®å€ã¯11ïŒãµã€ã¯ã«ãçµäºããããã®æ¡ä»¶ïŒã«ãªã£ãŠãããããããã«å¿ããŠãã¹ãŠã®èŠçŽ ã«å¯ŸããŠ11ã衚瀺ãããŸãã
æ£ãã解決çã¯ãèŠçŽ ããšã«åå¥ã«ã¯ãªãã¯åŠçé¢æ°ãåçã«çæããããšã§ãã
for(var counter=1; counter <=10; counter ++){ $('<div>').css({ "border": "solid 1px blue", "height": "50px", "margin": "10px", "text-align": "center", "width": "100px" }).html('<h1>'+ counter +'</h1>') .appendTo('body') .click((function(iCounter){ return function(){ alert(iCounter); } })(counter)); }
ãã®ã¢ãããŒãã§ã¯ã ã«ãŠã³ã¿ãŒããã©ã¡ãŒã¿ãŒãšããŠåãåããåçé¢æ°ãè¿ãå¿åé¢æ°ã䜿çšããŸãã å¿åé¢æ°å ã§ã¯ã ããŒã«ã«å€æ°iCounterã«ã¯ãé¢æ°ãåŒã³åºããããšãã®çŸåšã®ã«ãŠã³ã¿ãŒå€ãå«ãŸããŠããŸãã ãŸããé¢æ°ãåŒã³åºããã³ã«ãã¹ãŠã®ããŒã«ã«å€æ°ãå宣èšãããããïŒæ°ããã¯ããŒãžã£ãŒãäœæãããããïŒãå¿åé¢æ°ãåŒã³åºããããšãæ°ããããã€ãããã¯é¢æ°ãããæ¢ã«ãéãããçªå·ãšãšãã«è¿ãããŸãã
ç°¡åã«èšããšãé¢æ°ã2åïŒ3åç®ã4åç®...ïŒå®è¡ãããšããã¹ãŠã®ããŒã«ã«å€æ°ãã¡ã¢ãªå ã«åäœæãããåã®é¢æ°åŒã³åºãäžã«äœæãããå€æ°ãšã¯äœã®é¢ä¿ããããŸããã
é£ããã§ããïŒ åããŠã ãšæã-ã¯ãã ããããã°ããŒãã«å€æ°ãããããæã€å¿ èŠã¯ãªãããã©ãããç§ãåŒã³åºããã®ãããšããé¢æ°ã§ãã§ãã¯ãè¡ããŸãã ãããŠãããã©ã«ãã§æž¡ãããé¢æ°ãåŒã³åºãjQuery.eachã䜿çšãããšãã³ãŒãã¯ããã«ã·ã³ãã«ã§èªã¿ããããªããŸãã
$('div.handle-click').each(function(counter){ $(this).click(function(){ alert(counter); }); });
ã¯ããŒãžã£ãŒã®ãããã§ãçŸããç°¡æœã§ç解ããããã³ãŒããèšè¿°ããå¿ èŠã«å¿ããŠå€æ°ãšé¢æ°ã«ååãä»ããããšãã§ããŸãã ãŸãããã®ã³ãŒããä»ã®ãã©ã°å¯èœãªã¹ã¯ãªãããšç«¶åããªãããšã確èªããŠãã ããã
é衚瀺ã®ããã¹ã
å€æ°ã¯ããŒãžã£ã®ã¡ã«ããºã ã¯ãå
éšé¢æ°ããããã£[[Scope]]ã䜿çšããŠå®è£
ãããŸã-ãã®ãªããžã§ã¯ãã¯ãé¢æ°ã®å®£èšäžã«éå§ããã芪é¢æ°ã§å®£èšãããå€æ°ãžã®åç
§ãå«ã¿ãŸãã ãã®ãããäœæ¥ïŒåŒã³åºãïŒäžã«ããã¹ãŠã®ã芪ãå€æ°ãé¢æ°ã§äœ¿çšå¯èœã«ãªããŸãã å®éããªããžã§ã¯ã[[Scope]]ã¯ã¯ããŒãžã£ãŒã¡ã«ããºã ã®ããŒã§ãã
ééã¡ã«ããºã ã®è©³çŽ°ã«ã€ããŠã¯ããããã¯ã®äžã®ãªã³ã¯ã«ããèšäºãã芧ãã ããã
ééã¡ã«ããºã ã®è©³çŽ°ã«ã€ããŠã¯ããããã¯ã®äžã®ãªã³ã¯ã«ããèšäºãã芧ãã ããã
ãããã¿ã€ãã³ã°ãŸãã¯ãã¯ã©ã¹ãªããžã§ã¯ããäœæãããã
JavaScriptã®ãããã¿ã€ãã³ã°ã«ã€ããŠæžãããå€ãã®åªããèšäºããããŸãã ãããã£ãŠãç§ã¯ãã§ã«æžãããŠããããšãç¹°ãè¿ããªãããã«ããŸããããããã¿ã€ãã®ã¡ã«ããºã ã®åºç€ãåã«èª¬æããŸãã
JavaScriptã«ã¯ãªããžã§ã¯ãã®æŠå¿µããããŸãããã¯ã©ã¹ã®æŠå¿µã¯ãããŸããã
JavaScriptã§ã®ãªããžã§ã¯ãã®æäœã¯éåžžã«ç°¡åã§ãããªããžã§ã¯ãã宣èšããããããã£ãšã¡ãœãããå²ãåœãŠãã ãã§ãã
var dog = { "name": "Rocky", "age": "5", "talk": function(){ alert('Name: ' + this.name + ', Age: ' + this.age); } };
ãªããžã§ã¯ããå€æ°ããå Žåã¯ããªããžã§ã¯ããè¿ãå¥ã®é¢æ°ãäœæããæ¹ã䟿å©ã§ãã
function getDog(name, age){ return { "name": name, "age": age, "talk": function(){ alert('Name: ' + this.name + ', Age: ' + this.age); } }; } var rocky = getDog('Rocky', 5); var jerry = getDog('Jerry', 3);
ãããã¿ã€ãã䜿çšããŠãåãããšãã§ããŸãã
function Dog(name, age){ this['name'] = name; this.age = age; } Dog.prototype = { "talk": function(){ alert('Name: ' + this.name + ', Age: ' + this.age); } }; var rocky = new Dog('Rocky', 5); var jerry = new Dog('Jerry', 3);
åè¿°ã®ããã«ããããã¿ã€ãã¯ããã©ã«ãã®ããããã£ãšã¡ãœãããå«ãåçŽãªãªããžã§ã¯ãã§ãã ã€ãŸã ãªããžã§ã¯ãã§ããããã£ãååŸããããšãããããªããžã§ã¯ããæããªãé¢æ°ãåŒã³åºããšãJavaScriptã€ã³ã¿ãŒããªã¿ãŒã¯ãšã©ãŒãçæããåã«ããããã¿ã€ããªããžã§ã¯ãã§ãã®ããããã£/é¢æ°ãèŠã€ããããšããŸããèŠã€ãã£ãå Žåã¯ãããããã£/é¢æ°ãããã¿ã€ãã
é衚瀺ã®ããã¹ã
ãããã¿ã€ãã®ããããã£ã¯ãèªã¿åã/å®è¡ã«ã®ã¿äœ¿çšãããããšã«æ³šæããŠãã ããã å
ã®ããããã£ããªããžã§ã¯ãèªäœã§èŠã€ãããªãå Žåãå€ãžã®ã¢ã¯ã»ã¹/é¢æ°ã®å®è¡ãè©Šè¡ããå Žåã«ã®ã¿ãããããžã®ã¢ã¯ã»ã¹ãçºçããŸãã
ãªããžã§ã¯ãã«äœããã®ããããã£ïŒãããã¿ã€ãã§ã¯å©çšå¯èœã§ããããªããžã§ã¯ãã§ã¯å©çšäžå¯ïŒãå²ãåœãŠãããšãããšãããããã£ã¯ãªããžã§ã¯ãã§æ£ç¢ºã«äœæããããããã¿ã€ãã§ã¯å€æŽãããŸããã
ãªããžã§ã¯ãã«äœããã®ããããã£ïŒãããã¿ã€ãã§ã¯å©çšå¯èœã§ããããªããžã§ã¯ãã§ã¯å©çšäžå¯ïŒãå²ãåœãŠãããšãããšãããããã£ã¯ãªããžã§ã¯ãã§æ£ç¢ºã«äœæããããããã¿ã€ãã§ã¯å€æŽãããŸããã
JavaScriptã¯éåžžã«æè»ãªèšèªã§ãã ãããã£ãŠãæŠããŠããããã¿ã€ãã䜿çšããŠå®è¡ã§ããããšã¯ãã¹ãŠããããã¿ã€ããªãã§å®è¡ã§ããŸãã ãã ãããããã¿ã€ãã䜿çšãããšãå€æŽãšç¶æ¿ãããã³OOPã«è¿ãæ§æã«ããæè»ãªå¯èœæ§ãæäŸãããŸãã èå³ã®ããæ¹ã®ããã«ãèšäºã®æåŸã«ãç¬èªã®ã¯ã©ã¹ãå®è£ ããããã®ã¡ã«ããºã ãšå¯èœæ§ã®è©³çŽ°ãªèª¬æãå«ãèšäºãžã®ãªã³ã¯ããããŸãã
ãããŠããããã¿ã€ãã䜿çšããŠæ¢åã®ãªããžã§ã¯ãã®æ©èœãæ¡åŒµããå°ããªèª¬æçãªäŸ
ä»»æã®æ¥ä»ããææ¥ã®ååãååŸããå¿ èŠããããŸãããçµã¿èŸŒã¿ã®Dateãªããžã§ã¯ãã«ã¯getDayã¡ãœããã®ã¿ãå«ãŸããŠãããææ¥ã®æ°å€è¡šçŸã0ã6ã§è¿ããŸãïŒæ¥ææ¥ããåææ¥ã
ãããè¡ãããšãã§ããŸãïŒ
function getDayName(date){ var days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']; return days[date.getDay()]; } var today = new Date(); alert(getDayName(today));
ãŸãã¯ããããã¿ã€ãã³ã°ã䜿çšããŠãçµã¿èŸŒã¿ã®æ¥ä»ãªããžã§ã¯ããæ¡åŒµããŸãã
Date.prototype.getDayName = function(){ var days = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday']; return days[this.getDay()]; } var today = new Date(); alert(today.getDayName());
2çªç®ã®æ¹æ³ã¯ãããšã¬ã¬ã³ãã§ããäœåãªãé¢æ°ã§ã¹ã³ãŒããè©°ãŸãããããšã¯ãªããšæããŸããäžæ¹ãè€æ°ã®äººãã³ãŒãã«åãçµãã§ããå Žåãåã蟌ã¿ãªããžã§ã¯ãã®æ¡åŒµã¯æªã圢ã§ãããšããæèŠããããŸãããããã£ãŠãããã«ã¯æ³šæããå¿ èŠããããŸãã
å®è¡ã³ã³ããã¹ããŸãã¯ãThis Mysterious thisã
OOPã䜿çšãããŠããä»ã®ããã°ã©ãã³ã°èšèªããJavaScriptã«åãæ¿ãããšããã®ãªããžã§ã¯ããJavaScriptã§äœãæå³ããããç解ããããšã¯éåžžã«å°é£ã§ããç°¡åã«èª¬æããããšãããšãããã¯é¢æ°ãåŒã³åºããããªããžã§ã¯ããžã®åç §ã§ããäŸïŒ
var exampleObject = { "title": "Example Title", "showTitle": function(){ alert(this.title); } }; exampleObject.showTitle();
äŸãããããããã«ãexampleObject.showTitleïŒïŒãåŒã³åºããšãé¢æ°ã¯ãªããžã§ã¯ãã¡ãœãããšããŠåŒã³åºããããã®é¢æ°å ã§é¢æ°ãåŒã³åºããexampleObjectãªããžã§ã¯ããåç §ããŸããé¢æ°èªäœã¯ãªããžã§ã¯ãã«ã¯äžåä»å ããããåå¥ã«ååšããŸããã³ã³ããã¹ããã€ã³ãã£ã³ã°ã¯ãé¢æ°åŒã³åºãäžã«çŽæ¥çºçããŸãã
function showTitle(){ alert(this.title); } var objectA = { "title": "Title A", "showTitle": showTitle }; var objectB = { "title": "Title B", "showTitle": showTitle }; objectA.showTitle(); objectB.showTitle();
ãã®äŸã§æããã«ã³ãŒã«ããããšã瀺ããŠããobjectA.showTitleã¯ïŒïŒ ãããã¯ãåç §ObjectAã«ããšåŒã³åºãobjectB.showTitleãïŒïŒ - ObjectBã«äžãshowTitleé¢æ°èªäœã¯å¥åã«ååšããäœææã«ããããã£ãšããŠãªããžã§ã¯ãã«åçŽã«å²ãåœãŠãããŸãã
é¢æ°ãåŒã³åºããšãã«ãé¢æ°ïŒé¢æ°ïŒããªããžã§ã¯ããåç §ããªãå Žåãé¢æ°å ã®ããã¯ã°ããŒãã«ãŠã£ã³ããŠãªããžã§ã¯ããåç §ããŸããã€ãŸãåã«showTitleïŒïŒãåŒã³åºããšãã¿ã€ãã«å€æ°ã宣èšãããŠããªããšãããšã©ãŒãçæãããŸãããã ããã°ããŒãã«å€æ°titleã宣èšãããšãé¢æ°ã¯ãã®å€æ°ã®å€ãåºåããŸãã
var title = "Global Title"; function showTitle(){ alert(this.title); } showTitle();
é衚瀺ã®ããã¹ã
Strict Mode : , this window , this .
é¢æ°ã®ã³ã³ããã¹ããåŒã³åºãäžã«æ£ç¢ºã«æ±ºå®ãããããšã瀺ãããã«ãé¢æ°ããªããžã§ã¯ãã¡ãœãããšããŠã®ã¿æåã«ååšããäŸã瀺ããŸãã
var title = "Global Title"; var exampleObject = { "title": "Example Title", "showTitle": function(){ alert(this.title); } }; var showTitle = exampleObject.showTitle; // showTitle(); //
å®è¡ã®çµæãã¡ãã»ãŒãžãGlobal Titleãã衚瀺ãããŸããããã¯ãé¢æ°åŒã³åºãäžã«ããããexampleObjectãªããžã§ã¯ãã§ã¯ãªãã°ããŒãã«ãŠã£ã³ããŠãªããžã§ã¯ããæãããšãæå³ããŸããããã¯ãvarè¡ã®showTitle = exampleObject.showTitleã§é¢æ°ãžã®ãªã³ã¯ã®ã¿ãååŸããshowTitleïŒïŒãåŒã³åºããããšããã®åç §ããŠã£ã³ããŠãªããžã§ã¯ãã«ããå ã®exampleObjectãžã®åç §ããªãããã§ããç°¡åã«ããããã«ãé¢æ°ããªããžã§ã¯ãã®ããããã£ãšããŠåŒã³åºãããå Žåãããã¯ãã®ãªããžã§ã¯ããåç §ããŸããçºä¿¡è ãããªãå Žåããã
ã°ããŒãã«ãŠã£ã³ããŠãªããžã§ã¯ããåç §ããŸãã
ããããééãã®äŸïŒ
var exampleObject = { "title": "Example Title", "showTitle": function(){ alert(this.title); } }; jQuery('#exampleDiv').click(exampleObject.showTitle);
äºæ³ããããExample Titleãã§ã¯ãªãIDãexampleDivãã®DIVãã¯ãªãã¯ãããšã空ã®è¡ãŸãã¯DIVã®ãtitleãå±æ§ã®å€ã衚瀺ãããŸããããã¯ãã¯ãªãã¯ã€ãã³ãã«é¢æ°ãäžãããããªããžã§ã¯ãã«ã¯äžããªããšããäºå®ã«ãããã®ã§ãããããŠããã®çµæãå ã®exampleObjectãåç §ããã«é¢æ°ãèµ·åãããŸãïŒäŸ¿å®äžãjQueryã¯èŠçŽ èªäœã®ã³ã³ããã¹ãã§ãã³ãã©ãŒé¢æ°ãå®è¡ããåæ§ã®çµæã«ã€ãªãããŸãïŒããªããžã§ã¯ãã«ãã€ã³ããããé¢æ°ãéå§ããã«ã¯ããªããžã§ã¯ããžã®åç §ã䜿çšããŠé¢æ°ãåŒã³åºãå¿ èŠããããŸãã
jQuery('#exampleDiv').click(function(){ exampleObject.showTitle(); });
JavaScriptèªäœã䜿çšããŠããã®ãããªãäžåšçšãªã宣èšãåé¿ããã«ã¯ãbindã䜿çšããŠé¢æ°ãã³ã³ããã¹ãã«ãã€ã³ãã§ããŸãã
jQuery('#exampleDiv').click(exampleObject.showTitle.bind(exampleObject));
ãã ããããŒãžã§ã³9以åã®
jQuery('#exampleDiv').click(jQuery.proxy(exampleObject.showTitle, exampleObject)); // : jQuery('#exampleDiv').click(jQuery.proxy(exampleObject, "showTitle"));
ãã®ã¢ãããŒãã®æ¬è³ªã¯éåžžã«åçŽã§ããjQuery.proxyãåŒã³åºããããšãå¿åé¢æ°ãè¿ãããã¯ããŒãžã£ãŒã䜿çšããŠãæž¡ããããªããžã§ã¯ãã®ã³ã³ããã¹ãã§å ã®é¢æ°ãåŒã³åºãããŸãã
å®éãJavaScriptã¯ä»»æã®ã³ã³ããã¹ãã§ä»»æã®é¢æ°ãå®è¡ã§ããŸãããŸãããªããžã§ã¯ãã«æ©èœãå²ãåœãŠãå¿ èŠããããŸãããJavaScriptã§ãããè¡ãã«ã¯ãé©çšãšåŒã³åºãã® 2ã€ã®æ¹æ³ããããŸãã
function showTitle(){ alert(this.title); } var objectA = { "title": "Title A", }; var objectB = { "title": "Title B", }; showTitle.apply(objectA); showTitle.call(objectA);
é¢æ°ã®ãã©ã¡ãŒã¿ãŒã䜿çšããªããŠããäž¡æ¹ãšãåãããã«æ©èœããŸããé©çšé¢æ°ãšåŒã³åºãé¢æ°ã¯ãåŒã³åºããããšãã«ãã©ã¡ãŒã¿ãŒãæž¡ãããæ¹æ³ã®ã¿ãç°ãªããŸãã
function example(A, B, C){ /* code */ } example.apply(context, [A, B, C]); example.call(context, A, B, C);
åãäžããããŠãããããã¯ã®è©³çŽ°ã«ã€ããŠã¯ã次ãåç §ããŠãã ããã
- ç絡
- JavaScriptã®ã·ã§ãŒãã«ãã
- ã¯ããŒãžã£ãšJavaScriptãªããžã§ã¯ããéèš³ã®åçºæ
- ECMA-262-3ã®åŸ®åŠããããŒã4.å¯èŠæ§ã®ãã§ãŒã³ã
- JavaScriptã®ã¯ã©ã¹
- C / C ++ / CïŒ/ Javaããã°ã©ãåãã®JavaScriptãããã¿ã€ã
- JavaScriptã§ãªããžã§ã¯ããæäœããïŒçè«ãšå®è·µ
- ãã®ã³ã³ããã¹ãã®è©³çŽ°
- é¢æ°ããªããžã§ã¯ãã«ãã€ã³ãããŠã«ãªãŒåããïŒãbind / bindLateã
- ãã®javascriptããŒã¯ãŒã-å®éã«ã³ã³ããã¹ããå®çŸ©ããããšãåŠã¶