码迷,mamicode.com
首页 > 其他好文 > 详细

es6 Generator函数

时间:2020-07-26 15:13:08      阅读:51      评论:0      收藏:0      [点我收藏+]

标签:next   fun   generator   style   func   console   class   tor   span   

<script type="text/javascript">

    function* myGenerator(){
        console.log(‘业务逻辑A‘)
        let result=yield ‘hello‘
        console.log(result)
        console.log(‘业务逻辑B‘)
        yield ‘world‘
        console.log(‘执行完了‘)
    }

    let mg=myGenerator();
    console.log(mg.next())
    console.log(mg.next(‘hehe‘))
    console.log(mg.next())


</script>

 

es6 Generator函数

标签:next   fun   generator   style   func   console   class   tor   span   

原文地址:https://www.cnblogs.com/Essaycode/p/13379417.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!