Deleted articles cannot be recovered. Draft of this article would be also deleted. Are you sure you want to delete this article?
ããã«ã¡ã¯ï¼å°ç°å³¶ã§ããååã®ãã³ã¼ã«ããã¯ç·¨ããç´ç¨¿ããã¨ããã¢ã¤ãã£ããç»åã¯JavaScriptã®ãã´ã«ã¿ã¤ãã«ã®æåãå ¥ããã ãã¨ããã¨ãã§ããªããã£ã¤ãä»äºã ã£ãã®ã§ããããããã¬ç·¨éé¨ã®æ¹ã«ãã·ãªã¼ãºã§ç解ãæ·±ã¾ããã¨ãããããç ½ãæå¥ãã¤ããã¨ã¦ãã«ãã³ããç»åã«å·®ãæ¿ãã¦ããã ãã¾ãããã¢ã¤ãã£ããè©æ¬ºã«ãªããªãããã«ããã°ãã¾ãã éåæå¦çã·ãªã¼ãºã®2åç®ã¯Promiseã«ã¤ãã¦ã®èª¬æã§ããååã¯ã³ã¼ã«ããã¯ã«ã¤ãã¦èª¬æãã¾ããããPromiseã使ããã¨ã§ã©ã®ããã«ä¾¿å©ã«ãªã£ãã®ã§ãããããããã§ã¯è¦ã¦ããã¾ãããï¼ä»åã¯ã³ã¼ããå¤ãã®ã§ããªãåéãå¤ãæããããããããã¾ããããå®éã¯ãã¾ã大ãããã¨ã¯ããã¾ããã ä»åã®ç®ç ä»å説æããã®ã¯Promiseã§ããããã¯Futureãã¿ã¼ã³ï¼Promiseãã¿ã¼ã³ï¼ã¨ãããã¶ã¤ã³ãã¿ã¼ã³ã®ä¸ç¨®ã§ãECMAScript
JavaScript ãã¥ã¼ããªã¢ã« åç´ç·¨ JavaScript ã®åºç¤ JavaScript ã®ç¬¬ä¸æ© JavaScript ã®æ§æè¦ç´ JavaScript ãªãã¸ã§ã¯ãå ¥é JavaScript ã¬ã¤ã å ¥éç·¨ ææ³ã¨ãã¼ã¿å å¶å¾¡ããã¼ã¨ã¨ã©ã¼å¦ç ã«ã¼ãã¨ã¤ãã¬ã¼ã¿ã¼ é¢æ° å¼ã¨æ¼ç®å æ°ã¨æ¥ä» ããã¹ãå¦ç æ£è¦è¡¨ç¾ ã¤ã³ããã¯ã¹ä»ãã³ã¬ã¯ã·ã§ã³ ãã¼ä»ãã³ã¬ã¯ã·ã§ã³ ãªãã¸ã§ã¯ããå©ç¨ãã Using classes ãããã¹ã®ä½¿ç¨ JavaScript åä»ãé å ã¤ãã¬ã¼ã¿ã¼ã¨ã¸ã§ãã¬ã¼ã¿ã¼ ã¡ã¿ããã°ã©ãã³ã° JavaScript ã¢ã¸ã¥ã¼ã« ä¸ç´ç·¨ ã¯ã©ã¤ã¢ã³ããµã¤ã JavaScript ãã¬ã¼ã ã¯ã¼ã¯ ã¯ã©ã¤ã¢ã³ããµã¤ã Web API Language overview JavaScript ã®ãã¼ã¿æ§é çå¤æ¯è¼ã¨åä¸æ§ ããããã£ã®åæå¯è½æ§ã¨ææ権 ã¯ã
ã¯ããã«ï½åæå¦çã¨éåæå¦çã«ã¤ãã¦ï½ æ¬è¨äºã§ã¯ JavaScript ã®éåæå¦çãæ±ãããã® Promiseã¨ããä»çµã¿ã«ã¤ãã¦åãä¸ãã¾ãã JavaScriptãã¨ãã«ãµã¼ãã¼ãµã¤ãã§å©ç¨ãããNode.js ã§ã¯éåæå¦çãå©ç¨ããAPIãå¤æ°åºã¦ãã¾ãã Promise ã®ä»çµã¿ãç解ãã¦ããã¨ããã°ã©ã ã®ä½æãã¯ãã©ãã¯ãã§ãã ã¾ãæ¬é¡ã¸å ¥ãåã«ãåæå¦çãã¨ãéåæå¦çãã«ã¤ãã¦èª¬æããã¦ããã ãã¾ãã JavaScript ã®åæå¦ç åæå¦çã¨ã¯ä¸ããé çªã«å¦çããã¦ãããã¨ã§ãã å¦çãçµäºããã®ãå¾ ã£ã¦ããã次ã®å¦çãå®è¡ãã¾ãã 1console.log(1); 2console.log(2); 3console.log(3); [çµæ] 1 2 3 JavaScript ã®éåæå¦ç éåæå¦çã¨ã¯ã1ã¤ã®å¦çãçµäºããã®ãå¾ ããã«ã次ã®å¦çãå®è¡ãããã¨
Promiseã使ã£ãã«ã¼ãå¦çã®ãµã³ãã«ã¯ããã¤ããããã©ã Promiseã®çµæã使ã£ã¦whileã£ã½ãå¦çããããæ¹ããã¾ããªãã£ãã®ã§ã¡ã¢ã å¤ãªã¨ããããã£ã¨ããããæ¹ãããã°ã³ã¡ã³ããã ãã function loopUnit() { return new Promise(resolve => { /* ã«ã¼ãå¦çæ¬ä½ */ resolve(result) }) } function looper() { return new Promise(resolve => { // æ°¸ä¹ ã«ã¼ãã«ãªããªãããã«éçæ¡ä»¶ãå ¥ãã (optional) if ( /* éçæ¡ä»¶ */) { resolve() return } // ã«ã¼ãå¦ç loopUnit().then(result => { if ( /* whileæ¡ä»¶ */ ) { looper().then(() => res
ã¤ã³ãããã¯ã·ã§ã³ JavaScript ã使ãä¸ã§éåæå¦çãç¹ã« promise ãç解ãããã¨ã¯é常ã«éè¦ã§ãããasync/await ã promise ã®ä¸ã«æãç«ã£ã¦ããã®ã§ãpromise ãç解ãã¦å§ãã¦æ£ãã使ããã¨ãã§ããããã®è¨äºã§ã¯ JavaScript ã«ãããéåæå¦çãã©ã®ãããç解ã§ãã¦ãããããã§ãã¯ããããã®åé¡ãç´¹ä»ããã ããããã®ã³ã¼ãã«ã¤ãã¦ãå®è¡ããã¨ãã«ã³ã³ã½ã¼ã«ã«ä½ãã©ãããé åºã§åºåãããããèãã¦ã¿ããããªããã³ã¼ãã¯ãã©ã¦ã¶ã¼ã§å®è¡ãããã®ã¨ãã解ç㯠ECMAScript Specification 㨠HTML Living Standard ã«æ²¿ã£ããã®ã¨ãªã£ã¦ããã ð åç´ åé¡1.1 const p1 = Promise.resolve(1) const p2 = p1.then(x => x * 2) console
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}