Menu

1 / 2

Asynchronous JavaScript?

DEV Community: frontend·SATHISHKUMAR R·about 16 hours ago
#NHSiGUKr
#devtofrontend#devto#dev#start#console
Reading 0:00
15s threshold

SATHISHKUMAR R

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.