function sleep (time) {
return new Promise((resolve) => setTimeout(resolve, time));
}
// 异步执行
// sleep(3000).then(() => {
// // 这里写sleep之后需要去做的事情
// console.log('Do some thing, ' + new Date());
// })
// console.log('Do other things, ' + new Date());
console.log('Do some thing, ' + new Date());
setTimeout(async function(){
console.log('Do other things, ' + new Date());
}, 1000);
console.log('Do some thing, ' + new Date());
// 同步执行
// (async function() {
// console.log('Do some thing, ' + new Date());
// await sleep(3000);
// console.log('Do other things, ' + new Date());
// })();
console