skip to Main Content

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