BitlystBitlyst
PostsSeriesTopicsAbout

Bitlyst

Short, diagram-first posts on JavaScript, React & Next.js. Follow via RSS or the newsletter.

© 2026 Mohsen Fallahnejad

PostsSeriesTopicsLinksAboutRSSGitHubX
Posts/javascript
Beginner1 min read

Async vs Sync in JavaScript

Understand the difference between synchronous and asynchronous code in JavaScript with simple examples and analogies.

Mohsen Fallahnejad

Mohsen Fallahnejad

Sep 13, 2025Discuss

Let’s make it super simple.

1. What does synchronous mean?#

  • Sync = one by one, in order.
  • Like standing in line at a bakery: the cashier serves one customer at a time. The next person must wait until the first is done.
code
console.log("Step 1");
console.log("Step 2");
console.log("Step 3");

Output:

code
Step 1
Step 2
Step 3

2. What does asynchronous mean?#

  • Async = tasks can run in the background, don’t block others.
  • Like ordering food at a restaurant: you order, then do something else while the food is being prepared.
javascript
console.log("Step 1");

setTimeout(() => {
  console.log("Step 2 (after 2 seconds)");
}, 2000);

console.log("Step 3");

Output:

code
Step 1
Step 3
Step 2 (after 2 seconds)

3. Why does JavaScript care about async?#

  • JS runs on a single thread (one line at a time).
  • If everything were synchronous, one slow task (like fetching data) would freeze the whole page.
  • Async lets long tasks happen in the background → page stays smooth.

4. Quick mental model 🧠#

  • Sync = waiting in line at the bank.
  • Async = taking a number at the bank, sitting down, and getting called later while you can do other stuff.

⚡ That’s the core difference!

Filed under#javascript#async#sync#basics

Was this worth your time?

One tap tells me what to write more of.

Mohsen Fallahnejad

Written by

Mohsen Fallahnejad

Frontend engineer explaining JavaScript, React & Next.js internals in posts you can finish over coffee. More about me

X ↗GitHub ↗LinkedIn ↗
← OlderSOLID Principles Explained SimplyNewer →Event Bubbling vs Event Capturing in JavaScript

Start the discussion

Questions, corrections, a better approach? I read and reply to every comment.

Read next

queueMicrotask Explained: The Smallest Async Queue in JavaScript

What queueMicrotask does, how it differs from Promise.then, and how microtasks really work under the hood.

Dec 31, 20251 min read1

Why async/await Doesn’t Make JavaScript Code Parallel

Async/await feels like parallel code, but it isn’t. Here’s why JavaScript is still single-threaded and how async really works.

Dec 30, 20253 min read1

How Promise.all Works in a Single-Threaded JavaScript World

If JavaScript is single-threaded, how can Promise.all handle multiple requests at the same time? A deep dive into the event loop and async I/O.

Dec 30, 20252 min read1

Get new posts in your inbox

No spam. Unsubscribe any time.

1 min left
Discuss👍 React
👍