var x = new Promise((res)=>{ setTimeout(()=>{ console.log(1); res(); },1000); }); x.then(() => console.log(2));