JSFiddle - React, Tailwind, and code Playground
JavaScript
let id;
function main() {
let counter = 0;
id = setInterval(() => console.log(++counter), 500);
}
function getPromise() {
return new Promise(resolve => {
setTimeout(() => resolve(100), 3000);
});
}
async function other() {
console.log(">> awaiting...");
const ret = await getPromise();
console.log(">>> ret: ", ret);
clearInterval(id);
}
main();
other();