Tag

#array

19articles
BasicsNov 8, 2026

What is a dynamic array — and why push sometimes copies everything

A dynamic array in plain words: what capacity is, why push is almost always instant but sometimes copies the entire array, and when you'll actually notice.

6 min read
GuidesOct 13, 2026

Why changing one item changes all of them — three causes and fixes

Changed one item and they all changed? Three reasons every array item changes at once: fill, an object reused in a loop, a shared default — and fixes.

6 min read
BasicsOct 13, 2026

What is a sparse array — and why map won't fill Array(3)

What a sparse array is, in plain words: holes instead of elements. Why Array(3).map does nothing, and why the array's length lies to you.

5 min read
GuidesOct 7, 2026

How to split an array into chunks in JavaScript — without hitting a 429 from the API

How to chunk an array in JavaScript: a 3-line function, batch processing without 429 errors, a pause between batches, and two traps that freeze your tab.

6 min read
BasicsOct 2, 2026

some vs every in JavaScript — and why an empty list is "all done"

some vs every in JavaScript: the difference and which to pick. A comparison on five criteria, plus a trap: every on an empty array always returns true.

5 min read
GuidesOct 2, 2026

How to compare two arrays in JavaScript — and why [1, 2] doesn't equal [1, 2]

How to compare two arrays in JavaScript: in order, ignoring order, and with objects inside. Why === is always false and JSON.stringify lies about NaN.

6 min read
GuidesSep 29, 2026

How to shuffle an array in JavaScript — and why sort with Math.random cheats

How to shuffle an array in JavaScript fairly: write the Fisher–Yates shuffle step by step, test it in a minute, and see what's wrong with sort and Math.random.

6 min read
BasicsSep 28, 2026

What is a Set in JavaScript — and why it finds things thousands of times faster than an array

What a Set in JavaScript is, in plain words: a collection without duplicates and an instant has() check. When to pick a Set over an array — and where it quietly fails.

6 min read
GuidesSep 28, 2026

How to group an array in JavaScript — in one line instead of twelve

How to group an array of objects by a field in JavaScript: Object.groupBy, Map.groupBy and a fallback reduce. Step by step — from orders by status to spending by month.

6 min read
BasicsSep 28, 2026

filter or find — what's the difference, and why an if with filter always passes

filter or find in JavaScript: what each returns, which to pick when, and why if (arr.filter(...)) is always true. A comparison on five criteria and a clear verdict.

6 min read
GuidesSep 27, 2026

Why JavaScript sort sorts wrong — 10 lands before 9, plus 2 more causes

Why JavaScript sort orders numbers and words wrong: text comparison, a true/false comparator, and accented letters. How to check each cause and fix it.

6 min read
BasicsSep 27, 2026

What is the spread operator (...) in JavaScript — and why the order of three dots matters

The JavaScript spread operator in plain words: what three dots mean in code, how to copy and merge arrays and objects, and where the copy trap hides.

5 min read
BasicsSep 27, 2026

What is destructuring in JavaScript — and what [count, setCount] really means

Destructuring in JavaScript in plain words: pull fields out of objects and arrays in one line, read [count, setCount], and fix the Cannot destructure error.

5 min read
BasicsSep 27, 2026

slice vs splice in JavaScript — the difference, and why splice returns what you don't expect

slice vs splice in JavaScript: the difference and which to pick. Five criteria side by side, the splice return-value trap, and a safe replacement for React.

5 min read
GuidesSep 27, 2026

How to remove duplicates from an array in JavaScript — and why Set can't see identical users

How to remove duplicates from an array in JavaScript: a one-line Set for numbers and strings, cleaning case and spaces, and deduping objects by id.

6 min read
BasicsSep 24, 2026

for loop or map — which to use, and why await inside map doesn't wait

for loop or map in JavaScript: what's the difference and which to pick. A comparison on five criteria, where forEach fits, and the await-inside-map trap.

6 min read
GuidesSep 22, 2026

Why my array is empty — and why there's no error

The array is empty, the screen shows nothing, the console is silent. Three real causes of an empty array — data not there yet, a filter that cut everything, a list nested deeper — and how to check each.

5 min read
BasicsSep 22, 2026

What is an array — and why it counts from zero

What is an array in plain words: a list that keeps its order. Why counting starts at zero, where the most common beginner bug comes from, and why an empty array matters.

5 min read
BasicsSep 22, 2026

Array or object — which one to pick for your data

Array vs object: how they differ and which to pick for your data. A one-sentence rule, a breakdown by criteria, and why searching an array is a thousand times slower.

5 min read