{"id":280,"date":"2026-06-26T13:34:12","date_gmt":"2026-06-26T13:34:12","guid":{"rendered":"https:\/\/aabbee.cafe24.com\/?p=280"},"modified":"2026-06-26T13:34:12","modified_gmt":"2026-06-26T13:34:12","slug":"async-await","status":"publish","type":"post","link":"https:\/\/coalacoding.com\/async-await\/","title":{"rendered":"async&#8211;await"},"content":{"rendered":"<h2>\ucf5c\ubc31\uc9c0\uc625<\/h2>\n<blockquote>\n<p><strong>Info<\/strong>: <strong>\ube44\ub3d9\uae30\uc801 \ucc98\ub9ac\ub97c \ud560\ub550 \ucf5c\ubc31\uc744 \ud65c\uc6a9\ud558\uac8c \ub418\ub294\ub370 \ud558\ub2e4\ubcf4\uba74 \ucf5c\ubc31 \ud568\uc218\uac00 \uc911\ucca9\ub418\uba74\uc11c \ucf5c\ubc31 \uc9c0\uc625\uc5d0 \ube60\uc9c0\uac8c \ub41c\ub2e4.<\/strong><\/p>\n<\/blockquote>\n<ul>\n<li>1\ucd08\ud6c4\uc5d0 \uc77c\uc744 \ud558\ub294  timer \ud568\uc218\uac00 \uc788\ub2e4<\/li>\n<\/ul>\n<pre><code class=\"language-javascript\">timer(1000, function () {\n      console.log(&quot;\uc791\uc5c5&quot;);\n    });\n<\/code><\/pre>\n<ul>\n<li>timer \ud568\uc218\uc5d0 1\ucd08\ud6c4 \ucf5c\ubc31\ud568\uc218\ub97c \uc2e4\ud589\uc2dc\ud0a4\uace0 \ub610 \ucf5c\ubc31\uc744 \uc2e4\ud589\uc2dc\ud0a4\uac8c \ub420\uacbd\uc6b0\u2026 \ucf5c\ubc31\uc9c0\uc625\uc5d0 \ube60\uc9c0\uac8c\ub41c\ub2e4<\/li>\n<\/ul>\n<pre><code class=\"language-javascript\">timer(1000, function () {\n\tconsole.log(&quot;\uc791\uc5c5&quot;);\n  timer(1000, function () {\n    console.log(&quot;\uc791\uc5c5&quot;);\n    timer(1000, function () {\n      console.log(&quot;\uc791\uc5c5&quot;);\n    });\n  });\n});\n<\/code><\/pre>\n<h2>\ucf5c\ubc31\uc9c0\uc625\uc5d0\uc11c \ud0c8\ucd9c \u2192 promise<\/h2>\n<blockquote>\n<p><strong>Info<\/strong>: \ucf5c\ubc31\uc9c0\uc625\uc5d0\uc11c \ud0c8\ucd9c\ud558\uae30 \uc704\ud574\uc11c\ub294 promise \uac1d\uccb4\uc758 then \uc744 \uc0ac\uc6a9\ud55c\ub2e4.<\/p>\n<\/blockquote>\n<ul>\n<li>.then (\ud568\uc218)<\/li>\n<\/ul>\n<pre><code class=\"language-javascript\">timer(1000)\n\t.then(function () {\n\t\tconsole.log(&quot;\uc791\uc5c5&quot;);\n\t\treturn timer(1000);\n\t})\n\t.then(function () {\n\t\tconsole.log(&quot;\uc791\uc5c5&quot;);\n\t\treturn timer(1000);\n\t})\n\t.then(function () {\n\t\tconsole.log(&quot;\uc791\uc5c5&quot;);\n\t});\n<\/code><\/pre>\n<ul>\n<li>async &amp; await \ub85c \uc880\ub354 \uac04\ub2e8\ud788 \uc791\uc131<\/li>\n<\/ul>\n<pre><code class=\"language-javascript\">async function run(){\n\tawait timer(1000)\t\n\t\t\tconsole.log(&quot;\uc791\uc5c5&quot;);\n\tawait timer(1000);\n\t\t\tconsole.log(&quot;\uc791\uc5c5&quot;);\n\tawait timer(1000)\n\t\t\tconsole.log(&quot;\uc791\uc5c5&quot;);\n}\nrun();\n<\/code><\/pre>\n<h2>async &amp; await<\/h2>\n<blockquote>\n<p><strong>Info<\/strong>: then \uc744 \uc774\uc6a9\ud558\uc5ec \ucf5c\ubc31\uc744 \uc791\uc131\ud6c4 async\ub85c \ubcc0\uacbd\ud574\ubcf8\ub2e4<\/p>\n<\/blockquote>\n<ul>\n<li>.then (\ud568\uc218)\n<ul>\n<li>timer \ud568\uc218\ub294 promise \uac12\uc744 \ubc18\ud658\ud558\ub3c4\ub85d \uc791\uc131\ub418\uc5b4\uc788\ub2e4.<\/li>\n<li>then \ud568\uc218\ub97c \uc0ac\uc6a9\ud558\uc5ec 1\ucd08\ud6c4 \uc2e4\ud589\uc744 \ube44\ub3d9\uae30\uc801\uc73c\ub85c \uc5ec\ub7ec\ubc88 \uc2dc\ud0a4\ub294 \ucf54\ub4dc\ub97c \uc791\uc131\ud574\ubcf4\uc790<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<pre><code class=\"language-javascript\">function timer(time) {\n  return new Promise(function (resolve) {\n    setTimeout(() =&gt; {\n      resolve(time);\n    }, time);\n  });\n}\nconsole.log(&#39;start&#39;)\ntimer(1000)\n  .then((time) =&gt; {\n    console.log(&quot;time:&quot; + time);\n    return timer(time + 1000);\n  })\n  .then((time) =&gt; {\n    console.log(&quot;time:&quot; + time);\n    return timer(time + 1000);\n  })\n  .then((time) =&gt; {\n    console.log(&quot;time:&quot; + time);\n\t\tconsole.log(&#39;end&#39;)\n  });\n<\/code><\/pre>\n<p><img decoding=\"async\" src=\"https:\/\/aabbee.cafe24.com\/wp-content\/uploads\/2026\/06\/01-17.png\" alt=\"\"><\/p>\n<ul>\n<li>async &amp; await \ub85c \uc880\ub354 \uac04\ub2e8\ud788 \uc791\uc131<\/li>\n<\/ul>\n<pre><code class=\"language-javascript\">const run = async () =&gt; {\n  console.log(&quot;start&quot;);\n  let time = await timer(1000);\n  console.log(&quot;time:&quot; + time);\n  time = await timer(time + 1000);\n  console.log(&quot;time:&quot; + time);\n  time = await timer(time + 1000);\n  console.log(&quot;end&quot;);\n};\n\nrun();\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\ucf5c\ubc31\uc9c0\uc625 Info: \ube44\ub3d9\uae30\uc801 \ucc98\ub9ac\ub97c \ud560\ub550 \ucf5c\ubc31\uc744 \ud65c\uc6a9\ud558\uac8c \ub418\ub294\ub370 \ud558\ub2e4\ubcf4\uba74 \ucf5c\ubc31 \ud568\uc218\uac00 \uc911\ucca9\ub418\uba74\uc11c \ucf5c\ubc31 \uc9c0\uc625\uc5d0 \ube60\uc9c0\uac8c \ub41c\ub2e4. 1\ucd08\ud6c4\uc5d0 \uc77c\uc744 \ud558\ub294 timer \ud568\uc218\uac00 \uc788\ub2e4 timer(1000, function () { console.log(&quot;\uc791\uc5c5&quot;); }); timer \ud568\uc218\uc5d0 1\ucd08\ud6c4 \ucf5c\ubc31\ud568\uc218\ub97c \uc2e4\ud589\uc2dc\ud0a4\uace0 \ub610 \ucf5c\ubc31\uc744 \uc2e4\ud589\uc2dc\ud0a4\uac8c \ub420\uacbd\uc6b0\u2026 \ucf5c\ubc31\uc9c0\uc625\uc5d0 \ube60\uc9c0\uac8c\ub41c\ub2e4 timer(1000, function () { console.log(&quot;\uc791\uc5c5&quot;); timer(1000, function () { console.log(&quot;\uc791\uc5c5&quot;); timer(1000, function () { console.log(&quot;\uc791\uc5c5&quot;); }); &#8230; <a title=\"async&#8211;await\" class=\"read-more\" href=\"https:\/\/coalacoding.com\/async-await\/\" aria-label=\"async&#8211;await\uc5d0 \ub300\ud574 \ub354 \uc790\uc138\ud788 \uc54c\uc544\ubcf4\uc138\uc694\">\ub354 \uc77d\uae30<\/a><\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-280","post","type-post","status-publish","format-standard","hentry","category-javascript-basics"],"_links":{"self":[{"href":"https:\/\/coalacoding.com\/wp-json\/wp\/v2\/posts\/280","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/coalacoding.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coalacoding.com\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/coalacoding.com\/wp-json\/wp\/v2\/comments?post=280"}],"version-history":[{"count":1,"href":"https:\/\/coalacoding.com\/wp-json\/wp\/v2\/posts\/280\/revisions"}],"predecessor-version":[{"id":282,"href":"https:\/\/coalacoding.com\/wp-json\/wp\/v2\/posts\/280\/revisions\/282"}],"wp:attachment":[{"href":"https:\/\/coalacoding.com\/wp-json\/wp\/v2\/media?parent=280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coalacoding.com\/wp-json\/wp\/v2\/categories?post=280"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coalacoding.com\/wp-json\/wp\/v2\/tags?post=280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}