{"id":17350,"date":"2026-11-19T21:47:44","date_gmt":"2026-11-19T12:47:44","guid":{"rendered":"http:\/\/www.gisdeveloper.co.kr\/?p=17350"},"modified":"2026-11-19T21:48:17","modified_gmt":"2026-11-19T12:48:17","slug":"javascript%ec%97%90%ec%84%9c%ec%9d%98-asynciterator%eb%b9%84%eb%8f%99%ea%b8%b0-%eb%b0%98%eb%b3%b5%ec%9e%90","status":"publish","type":"post","link":"http:\/\/www.gisdeveloper.co.kr\/?p=17350","title":{"rendered":"JavaScript\uc5d0\uc11c\uc758 AsyncIterator(\ube44\ub3d9\uae30 \ubc18\ubcf5\uc790)"},"content":{"rendered":"<p>\ube44\ub3d9\uae30 \ubc18\ubcf5\uc790\ub294 \uc5ec\ub7ec\uac1c\uc758 \ub370\uc774\ud130\ub97c \uc21c\ucc28\uc801\uc73c\ub85c \ubc18\ubcf5\ud574\uc11c \uc5bb\uc744\ub54c \ube44\ub3d9\uae30\uc801\uc73c\ub85c \ucc98\ub9ac\ud558\ub294 \ubc18\ubcf5\uc790\ub97c \ub9d0\ud569\ub2c8\ub2e4. \uc989, \ube44\ub3d9\uae30\uc801\uc73c\ub85c \ub370\uc774\ud130\ub97c \ud558\ub098\uc529 \uc81c\uacf5\ud558\ub294 \uac1d\uccb4\uac00 \ube44\ub3d9\uae30 \ubc18\ubcf5\uc790\uc785\ub2c8\ub2e4. ok?<\/p>\n<p>\ube44\ub3d9\uae30 \ubc18\ubcf5\uc790\uac00 \uc788\uae30 \uc218\ub9cc\ub144\uc804\uc5d0 \uadf8\ub0e5 \ubc18\ubcf5\uc790\uac00 \uc788\uc5c8\uc2b5\ub2c8\ub2e4. \uadf8 \uc608\uc2dc\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"javascript\">\r\nfunction *getIterator() {\r\n    let i = 0;\r\n\r\n    for(let i=0; i<3; i++) {\r\n        yield i;\r\n    }\r\n}\r\n\r\nconst it = getIterator();\r\n\r\nconsole.log(it.next());\r\nconsole.log(it.next());\r\nconsole.log(it.next());\r\nconsole.log(it.next());\r\n\r\nfor(const it of getIterator()) {\r\n    console.log(it);\r\n}\r\n<\/pre>\n<p>\uacb0\uacfc\ub294 \ub2e4\uc74c\uacfc \uac19\uad6c\uc694.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.gisdeveloper.co.kr\/wp-content\/uploads\/2026\/11\/\u1109\u1173\u110f\u1173\u1105\u1175\u11ab\u1109\u1163\u11ba-2026-11-19-21.32.06.png\" alt=\"\" width=\"600\" class=\"aligncenter size-full wp-image-17352\" \/><\/p>\n<p>\ucf54\ub4dc\uac00 \ub3d9\uae30\uc801\uc73c\ub85c \ud55c\uc904\uc529 \uc21c\uc11c\ub300\ub85c \uc2e4\ud589\ub418\ub294 \uac83\uc744 \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<p>\uc774\uc81c \uc774\ubc88\uc5d0\ub294 \uc704\uc640 \ub3d9\uc77c\ud55c \uae30\ub2a5\uc774\uc9c0\ub9cc \ube44\ub3d9\uae30\uc801\uc73c\ub85c \uc2e4\ud589\ub418\ub294 \ucf54\ub4dc, \uc989 \ube44\ub3d9\uae30 \ubc18\ubcf5\uc790\uc758 \uc608\uc2dc\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"javascript\">\r\nasync function* getIterator() {\r\n    for (let i = 0; i < 3; i++) {\r\n        yield i;\r\n    }\r\n}\r\n\r\nconst it = getIterator();\r\n\r\nasync function test1() {\r\n    console.log(await it.next());\r\n    console.log(await it.next());\r\n    console.log(await it.next());\r\n    console.log(await it.next());\r\n}\r\n\r\ntest1();\r\n\r\nasync function test2() {\r\n    for await (const it of getIterator()) {\r\n        console.log(it);\r\n    }\r\n}\r\n\r\ntest2();\r\n<\/pre>\n<p>\uc77c\ubc18\uc801\uc778 \ubc18\ubcf5\uc790(\ub3d9\uae30 \ubc18\ubcf5\uc790)\ub97c \uc815\uc758\ud55c \ucf54\ub4dc\uc5d0\uc11c \ub2e8\uc9c0 async\ub9cc \ubd99\uc600\uc2b5\ub2c8\ub2e4. \uc774\ub807\uac8c \uc815\uc758\ud55c \ube44\ub3d9\uae30 \ubc18\ubcf5\uc790\ub97c \uc2e4\ud589\ud558\uae30 \uc704\ud574\uc11c\ub294 \uc5ed\uc2dc \ube44\ub3d9\uae30 \ud568\uc218\uac00 \ud544\uc694\ud558\ubbc0\ub85c test1, test2\ub77c\ub294 \ube44\ub3d9\uae30 \ud568\uc218\ub97c \uc774\uc6a9\ud558\uace0 \uc788\uc2b5\ub2c8\ub2e4. \uc2e4\ud589 \uacb0\uacfc\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.gisdeveloper.co.kr\/wp-content\/uploads\/2026\/11\/\u1109\u1173\u110f\u1173\u1105\u1175\u11ab\u1109\u1163\u11ba-2026-11-19-21.37.01.png\" alt=\"\" width=\"600\" class=\"aligncenter size-full wp-image-17357\" \/><\/p>\n<p>\uc2e4\ud589 \uacb0\uacfc\ub97c \ubcf4\uba74 \ube44\ub3d9\uae30\uc801\uc73c\ub85c \uc2e4\ud589\ub418\ub294 \uac83\uc744 \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<p>\uc2e4\ubb34\uc5d0\uc11c\ub294 \ube44\ub3d9\uae30 \ubc18\ubcf5\uc790\ub97c \uc815\uc758\ud558\ub294 \ud568\uc218\uc758 \uad6c\ud604\uc5d0 \ube44\ub3d9\uae30\uc801\uc73c\ub85c \uacb0\uacfc\ub97c \uc5bb\ub294 fetch \ub77c\ub4e0\uc9c0 \uc6f9\uc18c\ucf13 \ud1b5\uc2e0 \ub4f1\uc758 \ucf54\ub4dc\uac00 \ub4e4\uc5b4\uac11\ub2c8\ub2e4. \uc774\ub97c \ud749\ub0b4\ub0b4\uae30 \ubcf4\uba74..<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"javascript\">\r\nasync function* getIterator() {\r\n    for (let i = 0; i < 3; i++) {\r\n        const delay = Math.random() * 1000;\r\n        const result = await new Promise(resolve => {\r\n            setTimeout(() => {\r\n                resolve(i);\r\n            }, delay);\r\n        });\r\n\r\n        yield result;\r\n    }\r\n}\r\n\r\nconst it = getIterator();\r\n\r\nasync function test1() {\r\n    console.log(await it.next());\r\n    console.log(await it.next());\r\n    console.log(await it.next());\r\n    console.log(await it.next());\r\n}\r\n\r\ntest1();\r\n\r\nasync function test2() {\r\n    for await (const it of getIterator()) {\r\n        console.log(it);\r\n    }\r\n}\r\n\r\ntest2();\r\n<\/pre>\n<p>\uc0c1\uae30 \ucf54\ub4dc\uc758 \uacb0\uacfc\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.gisdeveloper.co.kr\/wp-content\/uploads\/2026\/11\/\u1109\u1173\u110f\u1173\u1105\u1175\u11ab\u1109\u1163\u11ba-2026-11-19-21.45.48.png\" alt=\"\" width=\"600\" class=\"aligncenter size-full wp-image-17360\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\ube44\ub3d9\uae30 \ubc18\ubcf5\uc790\ub294 \uc5ec\ub7ec\uac1c\uc758 \ub370\uc774\ud130\ub97c \uc21c\ucc28\uc801\uc73c\ub85c \ubc18\ubcf5\ud574\uc11c \uc5bb\uc744\ub54c \ube44\ub3d9\uae30\uc801\uc73c\ub85c \ucc98\ub9ac\ud558\ub294 \ubc18\ubcf5\uc790\ub97c \ub9d0\ud569\ub2c8\ub2e4. \uc989, \ube44\ub3d9\uae30\uc801\uc73c\ub85c \ub370\uc774\ud130\ub97c \ud558\ub098\uc529 \uc81c\uacf5\ud558\ub294 \uac1d\uccb4\uac00 \ube44\ub3d9\uae30 \ubc18\ubcf5\uc790\uc785\ub2c8\ub2e4. ok? \ube44\ub3d9\uae30 \ubc18\ubcf5\uc790\uac00 \uc788\uae30 \uc218\ub9cc\ub144\uc804\uc5d0 \uadf8\ub0e5 \ubc18\ubcf5\uc790\uac00 \uc788\uc5c8\uc2b5\ub2c8\ub2e4. \uadf8 \uc608\uc2dc\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4. function *getIterator() { let i = 0; for(let i=0; i { setTimeout(() => { resolve(i); }, delay); }); yield result; } } const it &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.gisdeveloper.co.kr\/?p=17350\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;JavaScript\uc5d0\uc11c\uc758 AsyncIterator(\ube44\ub3d9\uae30 \ubc18\ubcf5\uc790)&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[88],"tags":[],"class_list":["post-17350","post","type-post","status-publish","format-standard","hentry","category-javascript"],"_links":{"self":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/17350","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=17350"}],"version-history":[{"count":9,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/17350\/revisions"}],"predecessor-version":[{"id":17362,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/17350\/revisions\/17362"}],"wp:attachment":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=17350"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=17350"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=17350"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}