Your editable Javascript ... | The console results ... |
---|---|
const callback = () => console.log("Regular timeout callback has run"); const urgentCallback = () => console.log("*** Oh no! An urgent callback has run!"); const doWork = () => { let result = 1; queueMicrotask(urgentCallback); for (let i = 2; i <= 18; i++) { result *= i; } return result; }; console.log("Main program started"); setTimeout(callback, 0); console.log(`18! equals ${doWork()}`); console.log("Main program exiting"); |