async function fun(a) { var p = new Promise((resolve) => { if(a>=0) { setTimeout(() => resolve("positive"), 3000); } else { return "negative"; } }) var a = await p console.log(a); } fun(10); for(let i=0;i<3;i++) { console.log(i); }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter