JSFiddle - React, Tailwind, and code Playground
JavaScript
$(document).ready(function() {
alert("Running the program");
async function foo() {
let a = 0;
const foo = await (new Promise(resolve => setTimeout(() => resolve(123), 0)));
for (let i = 0; i < 1000000000; i++) {
a += Math.random() > 0.5 ? 1 : -1;
}
alert("I am running at Point A of the async function");
return [a, foo];
}
foo().then((v) => {
alert(`finally I get the value from the async function, and it is ${JSON.stringify(v)}`);
});
alert("This is after calling the async function");
});