function sleep(time){ console.log('insilde sleep') return new Promise((resolve)=>{ settimeout(resolve,time)}) } console.log('sleep') await sleep(2000) console.log('sleep2') (async function() { console.log('Do some thing, ' + new Date()); await sleep(3000); console.log('Do other things, ' + new Date()); })();