Grokking TypeScript
0% completed
Handling Asynchronous Functions
What order does this program print its three lines in?
console.log("Start"); setTimeout(() => { console.log("Timer finished"); }, 0); console.log("End");
Start End Timer finished
The timer asks for a delay of zero milliseconds, and its message still prints last. JavaScript runs one piece of code at a time, and it finishes the code that is already running before it starts anything else. Calling setTimeout only asks the runtime (the browser or Node.js) to call the function later, so the program continues with the next line.
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%