BitlystBitlyst
PostsSeriesTopicsAbout

Bitlyst

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

© 2026 Mohsen Fallahnejad

PostsSeriesTopicsLinksAboutSync devicesRSSGitHubX
← All topics

#javascript

32 posts

Packed vs Holey Arrays in V8: Why new Array(n) Makes Spread 4x Slower

V8 labels every array by what it holds and whether it may have gaps. Labels only get more general, and holey arrays take slower paths.

Nov 11, 20268 min read

How 'this' Works in JavaScript: Decided by the Call, Not the Code

'this' in JavaScript depends on how a function is called, not where it's written. Four rules and one arrow-function exception cover every case.

Nov 10, 20263 min read

JavaScript Classes Are Functions in a Costume (and What this.constructor Points To)

A JavaScript class is a function with stricter rules. Learn the three rules it adds and why this.constructor lets an object reach its own class.

Nov 10, 20264 min read

V8 Garbage Collection: Why Middle-Aged Objects Are the Expensive Ones

How V8's generational garbage collector works: scavenges cost per survivor, short-lived objects are nearly free, and pretenuring makes long-lived ones cheap.

Nov 6, 20267 min read

CPU Cache and JavaScript: Why Sorting an Array Can Make Loops 7x Slower

How memory locality and CPU cache misses affect JavaScript: why array order changes loop speed for large arrays of objects, and when typed arrays help.

Nov 6, 20265 min read

Sliced Strings in V8: How a 20-Character ID Keeps 1 MB Alive

Why slice() in V8 can keep a huge parent string alive, how sliced strings cause memory leaks in Node.js, and how to copy a string to release it.

Nov 6, 20265 min read

Hidden Classes in V8: Why Object Shape Changes Speed

How V8 hidden classes and inline caches work, why property reads get slower past four object shapes, and how to keep hot code monomorphic.

Nov 6, 20266 min read

Layout Thrashing: Why Reading offsetWidth in a Loop Freezes the Page

What layout thrashing and forced reflow are, why reading offsetWidth after a style change is slow, and how batching reads and writes fixes it.

Nov 6, 20265 min read

The $4.35 Item That Was Charged $4.34

Why 0.1 + 0.2 !== 0.3 in JavaScript, how floating-point math drops a cent when converting dollars to cents, and why money should be stored as integers.

Nov 3, 20265 min read

The Leaderboard Arrived Sorted. JavaScript Re-sorted It by User ID.

Why JavaScript object key order puts integer-like keys first in ascending order, how that silently reorders JSON from your API, and when to use an array or Map.

Nov 3, 20265 min read

JavaScript ASI: Why return on Its Own Line Gives undefined

How automatic semicolon insertion (ASI) turns `return` followed by a newline into `return;`, and the lines where JavaScript refuses to add a semicolon at all.

Nov 2, 20265 min read

You Selected Rows 3, 8, 12, 15 and 20. JavaScript Checked 3, 1 and 8.

Why ['1', '7', '11'].map(parseInt) returns [1, NaN, 3]: map passes the index as parseInt's radix. Plus the Number('') trap hiding in the obvious fix.

Nov 1, 20264 min read

The Leaderboard That Ranked 9 Points Above 100

Why JavaScript's sort() compares numbers as strings, why a 'lazy' comparator works in Safari but breaks in Chrome, and the one-line fix.

Oct 31, 20265 min read

Debounce vs Throttle — One Sentence to Remember Forever

Two patterns for taming fast events: debounce waits for silence, throttle limits how often. With examples, code, and interview answers.

Jul 8, 20264 min read

?? vs || — The Default-Value Trap That Breaks Real Apps

`||` treats 0 and '' as missing. `??` only treats null/undefined as missing. Know the difference before it bites you in an interview or in prod.

Jul 8, 20265 min read

JavaScript Generators & Iterators — Lazy Sequences Explained

Generators let you produce values on demand instead of all at once. Learn how iterators and generator functions work, and when to reach for them.

Jun 29, 20263 min read

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 read

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 read

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 read

Promise.all vs race vs any vs allSettled: When Do You Stop Waiting?

All four start your promises at once. The only difference is when each one stops waiting, and what counts as failure. Pick by that rule.

Dec 30, 20254 min read

Web Workers Explained for Frontend Developers

How Web Workers work, why they matter, and when to use them to achieve real parallelism in frontend apps.

Dec 30, 20253 min read

BroadcastChannel API in JavaScript

How to communicate between browser tabs, windows, or iframes easily using the BroadcastChannel API.

Oct 5, 20253 min read

Deep Copy vs Shallow Copy in JavaScript

Understand the difference between shallow and deep copies, with examples and pitfalls.

Sep 26, 20252 min read

AbortController & AbortSignal

Everything you need to cancel async work in JS: fetch, streams, custom tasks, React patterns, Node notes, timeouts, races, and common pitfalls.

Sep 23, 20254 min read

JavaScript Closures — A Simple Deep Dive

What closures are, how they work (lexical scope), and how to use them without pitfalls.

Sep 23, 20255 min read

JavaScript Promises Explained

A simple but deep dive into how Promises work in JavaScript and why they matter.

Sep 23, 20252 min read

JavaScript is Single-Threaded

Understand what it means when people say JS is single-threaded.

Sep 23, 20252 min read

JavaScript Event Bus 🚍 (JS + TypeScript)

A polished, practical event bus pattern with minimal JS, a strongly-typed TS version, wildcards, once-handlers, and React usage tips.

Sep 21, 20254 min read

JavaScript's Event Loop — Simple Guide (with SVG Timeline)

Event loop explained with a clean SVG timeline showing the actual execution order: Start → End → Promise → Timeout.

Sep 20, 20251 min read

Microtask vs Macrotask in JavaScript — With Node.js vs Browser Notes

Understand microtasks and macrotasks across browsers and Node.js, including process.nextTick, setImmediate, and event loop phases.

Sep 20, 20253 min read

Async vs Sync in JavaScript

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

Sep 13, 20251 min read

Event Bubbling vs Event Capturing in JavaScript

Understand how events travel through the DOM: bubbling (bottom-up) vs capturing (top-down) with simple examples and mental models.

Sep 13, 20251 min read

Related topics

#async#event loop#performance#gotchas#v8#interview#promises#arrays