I have the following code:
function asyncLoop() {
return new Promise(function(res, rej) {
for(let i=0;i<=400000000;i++) {
if(i===400000000) {console.log("done"); res();}
}
});
}
asyncLoop().then(()=>{console.log("then")});
console.log("out");
I am getting the following output:
done
out
then
According to my understanding of Promises, the asyncLoop should have run asynchronously and the following should have been the output:
out
done
then
What am I missing?