skip to Main Content

Order of asynchronous execution – Javascript

When I click 'CLICK ME' repeatedly and quickly, why is there a possibility that console.log(`===${innerCount}.2`); is executed earlier over console.log(`===${innerCount}.1`); Here is the CodeSandBox: https://codesandbox.io/s/loving-blackburn-v4k5y4?file=/src/App.js:651-666 throttle is from lodash. let count = 0; const App = () => { const…

VIEW QUESTION

JavaScript – sync + asyns code exectuction order – I want to understand why the logs are displayed in that order

Here is my piece of Vanilla TS code that I am trying to understand: console.log("-------------------------- (LOG 1)"); setTimeout(() => console.log("-----------------------------(LOG 2)"), 1000); const fetchedData = fetch("https://pokeapi.co/api/v2/pokemon/ditto"); const fnReturningNewPromise = () => { return new Promise<string>((resolve, reject) => { if (1…

VIEW QUESTION
Back To Top
Search