I want to understand what Async function do in js. If it actually runs code asynchronously then it should keep executing the code which is written after function call.
My code:
async function someWork(){
let p=10;
console.log("inside someWork");
//Some calculations to spend time
for(let i=0;i<100000000;i++){
b=i**i;
if(i==100000000-2){
console.log(i+" last Iteration, about to complete the calculation..");
}
}
console.log(p+" I am done With Long work");
}
console.log("before calling somework async function");
someWork();
console.log("after calling somework async function");
output:
before calling somework async function
inside someWork
99999998 last Iteration, about to complete the calculation..
10 I am done With Long work
after calling somework async function
However what I am expecting is:
before calling somework async function
after calling somework async function
inside someWork
99999998 last Iteration, about to complete the calculation..
10 I am done With Long work