Search⌘ K

What is Asynchronous?

Discover how JavaScript handles asynchronous programming by executing tasks without waiting for blocking code like network requests or timers. Learn how this single-threaded language uses asynchronous methods such as setTimeout to increase processing efficiency and improve application performance.

Background

JavaScript is a single-threaded language. At any time, only one instruction is processed by a JavaScript program. The program uses only one processor at any given time. Look at the following code for an example.

Node.js
for (var i = 0; i < 100; i++){
process.stdout.write(`${i} `);
}

In the above code, numbers are printed in a loop. The program runs entirely on the computer’s processor. The effective speed of computation is dependent on the processor’s speed. Only one instruction can be executed at the time. All instructions are executed so that no instruction is executed before the preceding ...