SOURCE

console 命令行工具 X clear

                    
>
console
// console.log('await 测试代码')
function timeout(time, str) {
	return new Promise((resolve) => {
  	// setTimeout(resolve, time * 1000)	
    setTimeout(() => {
      console.log('run end:', str);
      resolve(str)
    }, time * 1000)	
  });
}
async function main() {
  console.log('serial start')
  // await timeout(3);
  // console.log(123);  
  // 串行执行
  let strArr = ['a', 'b', 'c', 'd', 'e', 'f'];
  // for(let idx = 0; idx < 10; idx++) {
  //   await timeout(1, strArr[idx]);
  // }
  console.log('serial end');
  console.log('parrelel start');
  const promiseArr = [
  	timeout(1, '111'),
    timeout(2, '222'),
    timeout(3, '333'),
    timeout(1, '444'),
    timeout(2, '555')
  ];
  // 实际check log发现是并发请求的
  const res = await Promise.all(promiseArr);
  console.log(res, 'parrelel end');
  // Promie.all是不是并发请求
}

main();
<h1>await 测试代码</h1>