๐ย Reference
๐ Chapter
โฃ
โฃ
function* ํค์๋๋ก ๋ง๋ค๋ฉฐ, yield๋ผ๋ ํค์๋๋ฅผ ํตํด ํจ์๋ฅผ ์ค๊ฐ์ ๋ฉ์ถ ์ ์๋ ํน์ํ ํจ์์ด๋ค.์์ 1
function* myGenerator() {
console.log("1. ์ฒซ ์คํ");
yield "์ ์ ๋ฉ์ถค";
console.log("2. ๋ค์ ์์");
}
const gen = myGenerator();
gen.next(); // "1. ์ฒซ ์คํ" ์ถ๋ ฅ ํ ๋ฉ์ถค
gen.next(); // "2. ๋ค์ ์์" ์ถ๋ ฅ