JavaScript can start a task and continue executing other code without waiting for that task to finish.
Example:
console.log("Start");
setTimeout(() => {
console.log("Hello");
}, 2000);
console.log("End");
Output:
Start
End
Hello
Here, setTimeout() schedules the callback to run after approximately 2 seconds. JavaScript continues to the next line instead of waiting.
Top comments (0)