Suggest an editImprove this articleRefine the answer for “Async/sync callback”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)A **synchronous callback** runs **immediately**, in the same call stack, while an **asynchronous callback** is called **later**, on the next turn of the event loop, for example via a timer, a request, or an event. **Key point:** `array.map(fn)` is an example of a synchronous callback, while `setTimeout(fn, 0)` or `fetch().then(fn)` is an example of an asynchronous one.Shown above the full answer for quick recall.Answer (EN)Image### Synchronous callback > Runs **immediately**, during the call of the main function. > That is - **in the same call stack** (before the current function finishes). Example: ```javascript function process(callback) { console.log('Before the callback'); callback(); // runs immediately console.log('After the callback'); } process(() => console.log('Synchronous callback')); ``` Output: ```javascript Before the callback Synchronous callback After the callback ``` Everything runs **in order**, with no delays. --- ### Asynchronous callback > Called **later**, after the current code finishes - > for example, via a timer, after a request, an event, and so on. > That is - **on the next turn of the event loop**. Example: ```javascript function processAsync(callback) { console.log('Before the callback'); setTimeout(callback, 0); // runs later console.log('After the callback'); } processAsync(() => console.log('Asynchronous callback')); ``` Output: ```javascript Before the callback After the callback Asynchronous callback ``` The callback does not run **right away**, but after the call stack becomes free. --- **In short:** | Type | When it runs | Example | |---|---|---| | **Synchronous** | Immediately, during the call | `array.map(fn)` | | **Asynchronous** | Later, after the main code | `setTimeout(fn, 0)`, `fetch().then(fn)` |For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.