Horje
What is Asynchronous Code Execution ?

Asynchronous code execution refers to executing code where some tasks are executed out of order. In asynchronous code, operations don’t block subsequent code execution. Instead, tasks that take time to complete, such as I/O operations, network requests, or timers, are scheduled to run separately from the main execution flow. Asynchronous operations typically use callbacks, promises, or async/await syntax in JavaScript to handle the completion of tasks and execute code once the tasks are finished.

Example: Here, setTimeout() is an asynchronous operation that schedules the execution of its callback function after a specified delay (1 second). While waiting for the timeout to complete, the program continues executing the next line (console.log('Third')) without blocking, demonstrating asynchronous code execution. The output might appear as “First”, “Third”, and then “Second” after a 1-second delay.

Javascript

console.log('First');
setTimeout(() => {
    console.log('Second');
}, 1000);
console.log('Third');

Output:

First
Third
//after 1 second
Second



Reffered: https://www.geeksforgeeks.org


JavaScript

Related
What are IIFE (Immediately Invoked Function Expressions) ? What are IIFE (Immediately Invoked Function Expressions) ?
What is Debouncing in JavaScript ? What is Debouncing in JavaScript ?
What is Throttling in JavaScript ? What is Throttling in JavaScript ?
Difference Between Debouncing & Throttling in JavaScript Difference Between Debouncing & Throttling in JavaScript
What is Apply in JavaScript ? What is Apply in JavaScript ?

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
12