async&await

it2026-04-18  1

async function sleep(timeout) { return new Promise((resolve, reject) => { setTimeout(function() { resolve('timeout'); }, timeout); });}

(async function() { console.log('do something, ' + new Date()); await sleep(2000).then((value) => { console.log(value);}); console.log('Do other something, ' + new Date());}());

转载于:https://www.cnblogs.com/ax-null/p/6856656.html

相关资源:数据结构—成绩单生成器
最新回复(0)