Generator

作者: O8 | 来源:发表于2017-08-28 11:47 被阅读0次
    function *testGen() {
      console.log('print some');
      yield 1;
      yield 2;
      yield 3;
    }
    
    const it = testGen();
    it.next();  //1  { value: 1, done: false }
    it.next();  //2  { value: 2, done: false }
    it.next();  //3  { value: 3, done: false }
    it.next();  //undefined { value: undefined, done: false }

    相关文章

      网友评论

          本文标题:Generator

          本文链接:https://www.haomeiwen.com/subject/heiwdxtx.html