可以把以下代码复制到html文件中用chrome执行,或者用nodejs执行

function async1(chain) {
setTimeout(function(){
chain.next('async1') //2.恢复async1的等待
}, 1300);
} function async2(param,chain) {
setTimeout(function(){
chain.next(param + ' async2') //4.恢复async2的等待
}, 1100);
} var chain;
function *chainWrapper() {
var a = yield async1(chain); //1.等待async1完成执行
var b = yield async2(a,chain); //3.等待async2完成执行
console.log(b);//async1 async2
}
chain = chainWrapper(); chain.next();
05-08 15:51