JSFiddle - React, Tailwind, and code Playground
JavaScript
const loopAsync = async iter => new Promise(resolve => {
let n = 0;
while (n < iter * 1000000000) n++;
resolve(n);
});
loopAsync(1).then(console.log);
console.log('Main thread');
const loopAsync = async iter => new Promise(resolve => {
let n = 0;
while (n < iter * 1000000000) n++;
resolve(n);
});
loopAsync(1).then(console.log);
console.log('Main thread');