SOURCE

function* fibo() {
    let a = 0
    let b = 1

    yield a
    yield b

    while (true) {
        let next = a + b
        a = b
        b = next
        yield next
    }
}

let generator = fibo()

for (var i = 0; i < 10; i++) {
    console.log(generator.next().value) //=> 0 1 1 2 3 5 8 13 21 34 55
}
console 命令行工具 X clear

                    
>
console