es6 it yields simple to use

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>yield传参ld可以</title>
    <script src="./jquery3.1.0.js"></script>
</head>
<body>
<script>
    function *show(num1,num2) {
        console.log(`${num1},${num2}`)
        console.log('a')

        let a =yield ;
        console.log('b');
        console.log(a)
    }

    let gen = show(99,98);
    gen.next ( 111 );   // can not yield to the parameter passing 
    gen.next ( 123 );
 </ Script >

</body>
</html>

operation result

Guess you like

Origin www.cnblogs.com/malong1992/p/12129581.html