zoukankan      html  css  js  c++  java
  • 生成器函数实例

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>生成器函数实例</title>
    </head>
    <body>
        <script>
            //1s 控制台输出111 2s后输出222 3s后输出 333  总共是6s
            function one(){
                setTimeout(() =>{
                    console.log(111);
                    iterator.next()
    
                },1000)
            }
            function two(){
                setTimeout(() =>{
                    console.log(222);
                    iterator.next()
    
                },2000)
            }
            function three(){
                setTimeout(() =>{
                    console.log(333);
    
                },3000)
            }
    
            function * gen() {
                yield one();
                yield two();
                yield three();
    
            }
    
            //调用生成器函数
            let iterator = gen();
            iterator.next()
          
    
        </script>
    </body>
    </html>

  • 相关阅读:
    flash player over linux
    chmod 命令
    A*算法
    adb找不到设备
    ubuntu14.04安装wine以及国际版QQ
    linux man
    X-window
    linux file system
    linux command
    directUI
  • 原文地址:https://www.cnblogs.com/malong1992/p/13663877.html
Copyright © 2011-2022 走看看