Content deleted Content added
→ECMAScript: removed unnecessary blank lines |
|||
Line 482:
<source lang="javascript">
// inspired by: http://wiki.ecmascript.org/doku.php?id=harmony:generators
function* fibonacci() {
let init = 1;
yield init;
let [prev, curr] = [0, init];
while (true) {
[prev, curr] = [curr, prev + curr];
yield curr;
}
}
var gen = fibonacci();
console.log(gen.next().value); // 1
console.log(gen.next().value); // 1
Line 511 ⟶ 500:
console.log(gen.next().value); // 5
console.log(gen.next().value); // 8
</source>
|