Skip to content

Commit b0d280e

Browse files
committed
ES6 Generator 예시 추가
1 parent 6859423 commit b0d280e

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

‎function/example_yield.js‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
function* getNumbers(){
2+
yield 1;
3+
yield 2;
4+
return 3;
5+
}
6+
7+
function* getFibonacciSequence(){
8+
var a=0;
9+
var b=1;
10+
11+
yield a;
12+
yield b;
13+
14+
var next_value;
15+
while(true){
16+
next_value = a+b;
17+
a = b;
18+
b = next_value;
19+
yield next_value;
20+
}
21+
}

0 commit comments

Comments
 (0)