I know that JavaScript executes loops synchronously. So I don't understand why in the code below alert runs before the end of the for loop. I expected js to first complete the loop and then to execute the alert function. Instead, the for loop starts calling the console.log("loop"), and after a couple of seconds the alert gets executed while at the same time the console.log continuous to print the text "loop".
for(let i=0; i<100000; i++){
console.log("loop");
}
alert("hello world");