CodeZettaInterview Hub

JavaScript · Async JavaScript · Fresh / Intern · Concept

What is the difference between synchronous and asynchronous code in JavaScript?

Short Interview Answer

Synchronous code runs to completion on the call stack uninterrupted; asynchronous operations schedule work to continue later via the event loop without blocking the whole process (ideally).

Detailed Explanation

JS runs on a single main thread with a call stack. Long synchronous work blocks UI/events. Async APIs (timers, fetch, FS in Node) start work and register callbacks/promises that run later as tasks/microtasks. Async does not mean parallel CPU by itself — it means non-blocking scheduling. CPU-heavy work still needs workers/processes. Understanding this distinction prevents freezing the main thread and clarifies why `await` yields back to the event loop.

Interview Tip

Separate 'async' from 'parallel' — classic interviewer probe.

Common Mistake

Believing `async` functions run on another thread automatically.

Did you know this answer?