生成器函数参数

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>生成器函数参数</title>

</head>
<body>
<div id="ad">

</div>
<div></div>
<script>

    //生成器是个特殊函数

    function * gen(arg) {
        console.log(arg)
        let one = yield '第一部分';
        console.log(one);
        let two = yield '第二部分';
        console.log(two);
        let three = yield '第三部分';
        console.log(three);
    }

    let iterator = gen('student');
    iterator.next('one arg');
    iterator.next('two arg');
    iterator.next('three arg');

</script>
</body>
</html>

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-08
  • 2022-12-23
  • 2021-12-09
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-26
  • 2021-08-23
  • 2021-11-08
  • 2021-10-22
  • 2021-05-30
  • 2021-05-21
  • 2022-12-23
相关资源
相似解决方案