<script>
    function * gen(){
        yield 'welcome';
        yield 'to';
        yield '吾爱博客';
    }

    let g1 = gen();
    
    // v1 = g1.next()
    // console.log(v1.value,v1.done)
    // v1 = g1.next()
    // console.log(v1.value,v1.done)
    // v1 = g1.next()
    // console.log(v1.value,v1.done)
    // v1 = g1.next()
    // console.log(v1.value,v1.done)

    for (const iterator of g1) {
        console.log(iterator)
    }

    console.log(...gen())
</script>

输出

welcome
to
吾爱博客
welcome to 吾爱博客

版权声明:本文为原创文章,版权归 吾爱博客 所有,转载请联系博主获得授权!
本文地址:https://www.52bd.net/html/165.html

发表评论

正在加载 Emoji
×