mirror of
https://github.com/ruanyf/es6tutorial.git
synced 2025-05-28 21:32:20 +00:00
修改generator
This commit is contained in:
parent
72b6fdeb73
commit
20c74cbe52
@ -275,7 +275,7 @@ function *foo() {
|
|||||||
return 6;
|
return 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var v of foo()) {
|
for (let v of foo()) {
|
||||||
console.log(v);
|
console.log(v);
|
||||||
}
|
}
|
||||||
// 1 2 3 4 5
|
// 1 2 3 4 5
|
||||||
@ -296,7 +296,7 @@ function* fibonacci() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (n of fibonacci()) {
|
for (let n of fibonacci()) {
|
||||||
if (n > 1000) break;
|
if (n > 1000) break;
|
||||||
console.log(n);
|
console.log(n);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user