DEV Community

Discussion on: Explain Async/Await Like I'm Five

Collapse
 
minhng97 profile image
Minh Nguyen • Edited

Async:

async function loadThis(){
 var loadedData = await fetch(URL); //wait for this and not execute the next line
return loadedData;
}
alert(loadThis);

Promise:

var s = function(){return Promise.resolve(URL).then(result => alert(result);
}
s()