Tag

#javascript

102articles
BasicsNov 2, 2026

What is a Web Worker — and why await doesn't stop your page from freezing

What is a Web Worker in plain words: a second thread for heavy JavaScript, how it talks to the page, why data gets copied, and when you don't need one.

5 min read
GuidesNov 2, 2026

How to detect a touch screen in JavaScript and CSS — and why ontouchstart lies

How to detect a touch device on a website: step by step with CSS @media (hover) and (pointer), matchMedia and pointerType — and why ontouchstart gets it wrong.

6 min read
BasicsNov 1, 2026

What is Big O notation — and why your code flew on 100 rows and died on 100,000

What Big O notation means in plain words: how to tell how much slower code gets as data grows, and why includes inside a loop is a quiet time bomb.

6 min read
BasicsNov 1, 2026

What is a source map — and why your error points to line 1, column 48213

What a source map is in plain words: how it turns an error in minified code into the right line of your file, and why you shouldn't publish it openly.

6 min read
BasicsNov 1, 2026

What is a polyfill — and how one such script infected 100,000 sites

What a polyfill is in plain words: how it adds missing functions to a browser, how it differs from transpiling, and when you actually still need one.

6 min read
GuidesNov 1, 2026

How to measure how long code takes in JavaScript — and why the first run always lies

How to measure code execution time in JavaScript: step by step with console.time and performance.now, warm-up, median, async code, and why not Date.now.

6 min read
BasicsOct 31, 2026

What is an LRU cache — and why a cache with no limit becomes a memory leak

LRU cache explained simply: how it decides what to evict, why a plain-object cache eats your memory, and how to build an LRU on a JavaScript Map in 15 lines.

5 min read
GuidesOct 31, 2026

How to detect when the user goes offline — and why navigator.onLine lies in a café

How to detect offline in JavaScript: what navigator.onLine really means, the online and offline events, and a fetch check with a timeout.

6 min read
BasicsOct 31, 2026

encodeURI vs encodeURIComponent — the difference, and why 'Tom & Jerry' searches for 'Tom'

encodeURI vs encodeURIComponent: which one to use for URL parameters, why & and + break your search, what %2520 means, and why URLSearchParams beats both.

5 min read
GuidesOct 29, 2026

How to detect an element's size change — and why window.resize stays silent

How to detect an element's size change in JavaScript: step by step with ResizeObserver, why window resize doesn't fire, and how to fix the ResizeObserver loop error.

6 min read
BasicsOct 27, 2026

What is a Proxy in JavaScript — and why the console says Proxy(Object)

What a JavaScript Proxy is in plain words: how a middleman object intercepts reads and writes, what powers Vue reactivity, and three traps where it breaks.

6 min read
01
GuidesOct 14, 2026

How to calculate the number of days between two dates in JavaScript — and why you get one day too few

How to calculate days between two dates in JavaScript without an off-by-one: time of day, time zones, input type=date and Temporal. A ready function plus tests.

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
BasicsOct 13, 2026

input vs change event — and why your search only fires after clicking away

input vs change in JavaScript: when each event fires, which one to use for search, sliders and checkboxes — and why React's onChange works differently.

5 min read
GuidesOct 13, 2026

How to capitalize the first letter — without turning iPhone into Iphone

How to capitalize the first letter of a string in JavaScript and CSS: step by step, with empty strings, leading quotes, Turkish i and names like McDonald.

6 min read
GuidesOct 12, 2026

Why strings aren't equal even though they look identical — 5 invisible causes

Why identical-looking strings aren't equal in JavaScript: hidden spaces, \r, non-breaking spaces, BOM, two codes for one letter, lookalike letters — and fixes.

6 min read
BasicsOct 12, 2026

What is type coercion — and why your cart says "10050" instead of 150

What type coercion in JavaScript is, in plain words: why "5" + 2 gives "52" while "5" - 2 gives 3, and how to stop shipping these bugs in your code.

6 min read
BasicsOct 12, 2026

What is a mutex — and why single-threaded code needs a lock

What a mutex is, in plain words: how a lock saves you from double charges and logouts in another tab, and where to get a mutex in JavaScript and in a database.

6 min read
GuidesOct 12, 2026

How to count words in a string in JavaScript — and why split(" ") lies

How to count words in a string in JavaScript: why split(" ") gets spaces and dashes wrong, and how to handle hyphens, Japanese text and emoji. With ready code.

6 min read
BasicsOct 11, 2026

What is optional chaining (?.) in JavaScript — and why it doesn't stop every crash

Optional chaining (?.) in plain words: how it stops “Cannot read properties of null”, where it still crashes, and why not to use it everywhere.

5 min read
BasicsOct 11, 2026

What is a prototype in JavaScript — and why an empty object isn't empty

What a prototype is in JavaScript: where objects get properties you never added, why a word counter breaks on “constructor”, and why __proto__ is risky.

6 min read
BasicsOct 11, 2026

What is a closure in JavaScript — and why your counter is stuck at 1

What a closure is in plain words: a function that remembers the variables from where it was born. And why it makes a React timer show 1 forever.

5 min read
BasicsOct 11, 2026

preventDefault vs stopPropagation — what's the difference and which to use

preventDefault vs stopPropagation in plain words: what each one stops, why AI adds both “just in case”, and how that breaks menus and analytics. Which to pick.

5 min read
GuidesOct 11, 2026

How to pluralize words after numbers in JavaScript — “1 file, 2 files” in any language

How to pluralize words after numbers in JavaScript: why n === 1 breaks in Russian and Polish, how Intl.PluralRules picks the form, and which numbers to test.

6 min read
GuidesOct 10, 2026

Why your regex in JavaScript works every other time — and what the g flag has to do with it

Why a JavaScript regex works every other time: test() with the g flag remembers lastIndex. Three common causes, how to confirm each, and how to fix it.

6 min read
BasicsOct 10, 2026

What is a WeakMap in JavaScript — and why a Map cache quietly eats memory

What a WeakMap is, in plain words: a dictionary that doesn't keep its keys alive. Why a cache built on a plain Map leaks, and when WeakMap is the right fix.

5 min read
BasicsOct 10, 2026

What is a template literal in JavaScript — and why a pair of parentheses opens an SQL injection

What template literals in JavaScript are: backticks, ${} interpolation, tags like sql`` — and the one mistake that turns a safe query into an SQL injection.

6 min read
BasicsOct 10, 2026

What is a Symbol in JavaScript — and why JSON.stringify can't see it

What a Symbol in JavaScript is, in plain words: a key that skips JSON and Object.keys, breaks string concatenation, and is the reason for...of works at all.

5 min read
BasicsOct 10, 2026

localStorage vs sessionStorage — and why the cart vanishes in a new tab

localStorage vs sessionStorage: how they differ, how long data lives, why sessionStorage is empty in a new tab but copied when you duplicate one — and which to pick.

5 min read
GuidesOct 10, 2026

How to check if an object is empty in JavaScript — and why Date and Map look empty

How to check if an object is empty in JavaScript: why if (obj) fails, where Object.keys and JSON.stringify lie, and a ready 4-line function that gets it right.

6 min read
GuidesOct 9, 2026

Why big numbers get rounded in JavaScript — and your API ID ends in zeros

Why big numbers get rounded in JavaScript: an ID from your API arrives ending in zeros. Three causes — JSON.parse, Number() and Excel — and how to fix each.

6 min read
BasicsOct 9, 2026

What is short-circuit evaluation — and where that stray «0» on screen came from

What is short-circuit evaluation (&& and ||), in plain words: why the second half may never run, and where a lone zero in your React UI comes from.

5 min read
BasicsOct 9, 2026

What is a bitmask — and why permissions=8 makes your bot an admin

What is a bitmask, in plain words: many yes/no flags packed into one number. Explained with Discord bot permissions, chmod 755 and a JavaScript trap.

5 min read
BasicsOct 9, 2026

for vs while loop — which to pick, and why infinite loops live in while

for vs while loop: the difference and which to choose. Compared on five criteria, plus when you need do...while and how to fetch every API page safely.

5 min read
GuidesOct 8, 2026

Why your object keys are out of order — and the list sorts itself

Why object key order changes in JavaScript: integer keys jump to the front, databases and JSON don't keep order. Three causes, how to check and how to fix.

5 min read
BasicsOct 8, 2026

What is a higher-order function — and why map(parseInt) breaks your numbers

A higher-order function, explained simply: a function that takes or returns another function. Why map(parseInt) gives NaN and how to read this kind of code.

5 min read
BasicsOct 8, 2026

setTimeout vs requestAnimationFrame — and why your animation runs twice as fast on an iPhone

setTimeout vs requestAnimationFrame: which to use for animation, timers and games. Why animations stutter and speed up on 120 Hz screens — and how to fix it.

5 min read
GuidesOct 8, 2026

How to flatten an array — and why flat() doesn't finish the job the first time

How to turn a nested array into a flat one in JavaScript: flat, flatMap and flat(Infinity) step by step. Why arrays remain inside after flat() and how not to lose data.

6 min read
GuidesOct 7, 2026

Why console.log shows the wrong value — and how the console "lies" to you

Why console.log shows the wrong value: one thing collapsed, another expanded, an empty array full of data, or [Object] instead of nested fields. Three causes.

5 min read
BasicsOct 7, 2026

What is a reducer — and why the screen didn't update even though the data changed

What is a reducer in simple terms: how reduce and useReducer work, why mutating state won't re-render the screen, and why an empty array can crash it.

5 min read
BasicsOct 7, 2026

What is a generator in JavaScript — and why a function with a star doesn't run

What is a generator in JavaScript in simple terms: how function* and yield work, why calling one does nothing, and where generators hide in AI streaming.

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 7, 2026

async or defer on a script tag — and why async breaks your site every other load

async or defer: the difference for the script tag and which to pick. A comparison on five criteria, plus the trap: async scripts run in a random order.

5 min read
BasicsOct 2, 2026

What is the event loop — and why setTimeout with zero fires last

What is the event loop in JavaScript, in plain words: why setTimeout(0) waits for promises and why a heavy loop freezes the whole page.

6 min read
BasicsOct 2, 2026

What is memoization — and why a cache keyed by an object never hits

What is memoization, in plain words: a function remembers its answers. Why the cache stays silent when you pass an object, and when it freezes your data.

6 min read
BasicsOct 2, 2026

What is event delegation — and why new buttons won't click

What is event delegation in JavaScript, in plain words: one handler on the parent instead of a hundred, and why buttons added later stay silent.

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
GuidesOct 1, 2026

Why localStorage data disappears — four causes and how to check each

Why localStorage loses data after a reload: your code overwrites it, a different port, an object saved without JSON.stringify, the browser wiping it. Fixes.

5 min read
BasicsOct 1, 2026

includes vs indexOf — and why your check lets the guest in but not the admin

includes vs indexOf in JavaScript: how they differ, what they return and when to use which. Plus the if (indexOf(...)) bug that makes a check work backwards.

4 min read
GuidesOct 1, 2026

How to wait in JavaScript — and why await inside forEach doesn't wait

How to pause (sleep) in JavaScript: a setTimeout and await delay, pausing in a loop between requests, and the forEach trap that never waits. With code.

5 min read
GuidesSep 30, 2026

Maximum call stack size exceeded — why it happens and how to fix it, even without recursion

The Maximum call stack size exceeded error in JavaScript: three real causes, including Math.max on a big array and a setter that calls itself. How to find and fix each one.

6 min read
BasicsSep 30, 2026

What is an enum — and why JavaScript doesn't have one and TypeScript is moving away from it

What an enum is, in plain words: a closed list of allowed values. The bug it catches, why JavaScript has no enum, and what to write instead of enum in TypeScript.

5 min read
BasicsSep 30, 2026

What is a stack in programming — and why Ctrl+Z works the way it does

What a stack is, in plain words: a pile where the last thing in is the first thing out. How Ctrl+Z, the Back button and the call stack in your code are built on it.

5 min read
BasicsSep 30, 2026

What is a default parameter — and why in Python it can 'remember' the last call

What a default parameter is, in plain words: the value a function uses when you don't pass one. Two traps — null in JavaScript and a shared list in Python.

5 min read
GuidesSep 30, 2026

How to format numbers and prices in JavaScript — separators, currencies and the toFixed trap

How to format numbers and prices in JavaScript: thousands separators, currencies, percentages and '1.2M' with Intl.NumberFormat. Plus why toFixed rounds 1.005 to 1.00.

6 min read
BasicsSep 29, 2026

What is an operator in programming — and why -1 % 5 breaks your carousel

What an operator is in plain words: plus, remainder, comparison. How operators solve real tasks — and where the trap with negative numbers hides.

5 min read
BasicsSep 29, 2026

What is a random number in programming — and why a computer can't roll a die

What a random number is in code and how Math.random works: why it's pseudo-random, where the Math.round trap hides, and when you need crypto instead.

5 min read
BasicsSep 29, 2026

innerHTML vs textContent — the difference, and why a username can run code

innerHTML vs textContent: what's the difference and which to use. A five-criteria comparison, how innerHTML opens a hole for foreign code, and where innerText fits.

5 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
GuidesSep 28, 2026

Why my event fires twice — three causes and how to fix each one

A click or key press fires twice, or even more? Three real causes of an event firing twice in JavaScript and React — and how to check and fix each one.

6 min read
BasicsSep 28, 2026

What is hoisting — and why you can call a function before you've written it

What hoisting in JavaScript is, in plain words: why a function works before it's declared, const crashes with an error, and var quietly gives you undefined.

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
BasicsSep 28, 2026

What is a Map in JavaScript — and why an object secretly turns your keys into text

What a Map in JavaScript is, in plain words: a dictionary where any value can be a key. How Map differs from an object and from the .map() method — and when to use it.

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

What is a pure function — and why React deliberately runs your code twice

What a pure function is in programming, in plain words: same input, same output, no side effects. Why it matters in React and in tests, with examples.

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
GuidesSep 26, 2026

"is not a function" error — why it happens and how to fix it

TypeError: x is not a function — what this JavaScript error means and how to fix it. The three common causes: wrong data type, a made-up method, the import.

5 min read
BasicsSep 26, 2026

What is try catch — and why it sometimes doesn't catch the error

What is try catch, in plain words: a safety net for your code. How it works, why you need finally, and why try without await catches nothing.

5 min read
BasicsSep 26, 2026

What is a data type — and why JavaScript thinks null is an object

What is a data type, in plain words: a label that tells a program how to read a value. The main types, how to check them, and where the bugs come from.

5 min read
BasicsSep 26, 2026

for in vs for of — the difference, and why for in hands you strings instead of numbers

for in vs for of in JavaScript, explained simply. Why for in over an array gives "0" and "1" as strings, why for of crashes on an object — and which to pick.

5 min read
GuidesSep 25, 2026

Why this is undefined in JavaScript — 3 causes and how to fix them

Why this is undefined in JavaScript and where “Cannot read properties of undefined” in a method comes from: a callback, a function inside a method, an arrow.

6 min read
BasicsSep 25, 2026

What is an if statement in programming — and why branch order decides everything

What an if statement is, in plain words: a fork in the code, “if — else”. Why code checks branches top to bottom and how one wrong order breaks discounts.

5 min read
BasicsSep 25, 2026

What is a class in programming — the blueprint code uses to stamp out objects

What a class is in programming, in plain words: a blueprint for objects. How a class differs from an object, what new does, and why AI writes classes.

5 min read
GuidesSep 25, 2026

How to split code into files — export and import in 6 steps, without breaking anything

How to split one long code file into several: export, import and paths between files, step by step. Plus a prompt so AI does it for you without breaking it.

6 min read
BasicsSep 25, 2026

Function vs method — what's the difference, and why it isn't about how they're written

Function vs method: the difference in plain words. Why Python uses len(x) and not x.len(), what this gives a method, and when to write each one.

5 min read
GuidesSep 24, 2026

Why you get NaN in JavaScript — 3 causes and how to find where it came from

Why JavaScript gives you NaN instead of a number: an empty field, text instead of a number, zero divided by zero. How to find the source of NaN and fix it fast.

6 min read
BasicsSep 24, 2026

What is a string in programming — and why "5" and 5 aren't the same

What a string is, in plain words: text in quotes. Why "2" + "2" gives "22", an emoji counts as two characters, and everything from a form arrives as a string.

5 min read
BasicsSep 24, 2026

What is return and a return value — and why console.log returns nothing

What return does in a function, in plain words: the answer a function hands back. Why console.log shows a number but your variable holds undefined.

5 min read
BasicsSep 24, 2026

What is a boolean — and why the string "false" is actually true

What a boolean is, in plain words: true or false. Why "false" in quotes counts as true, an empty array does too, and zero counts as false.

5 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 24, 2026

How to convert a string to a number in JavaScript — without tripping on a comma

How to turn a string into a number in JavaScript: Number, parseInt or parseFloat. Step by step — with empty fields, spaces in "1 200" and a decimal comma.

6 min read
GuidesSep 23, 2026

Why my loop never stops — and the tab freezes solid

An infinite loop: the tab froze, the fan is screaming, the server gets thousands of requests. Three real causes — from React useEffect to while — how to check and fix.

6 min read
BasicsSep 23, 2026

What is an object in programming — and why two identical objects aren't equal

What an object in programming is, in plain words: a card with labeled fields. How it works, where it shows up in AI-written code, and why {a:1} isn't {a:1}.

5 min read
BasicsSep 23, 2026

let vs const — which to use, and why AI writes const almost everywhere

let vs const in JavaScript: what the difference is and which to pick. A criteria breakdown, a one-second rule, and why const doesn't mean "can't change."

5 min read
GuidesSep 16, 2026

How to add a share button to your site — the phone's own share sheet, no social widgets

How to build a share button with the Web Share API: the phone's native share sheet, a fallback for desktop, and three mistakes that quietly break it.

6 min read
GuidesSep 15, 2026

How to add a “Copy” button — and why it stays silent on http

How to add a copy button to your site: navigator.clipboard in five steps, a “Copied” confirmation for screen readers, and three reasons copying fails.

7 min read
BasicsSep 9, 2026

What is tree shaking — and why lodash still ships to your bundle whole

Tree shaking drops unused code from your build. Here's why it works with some libraries and silently does nothing at all with others.

5 min read
BasicsSep 9, 2026

What is code splitting — and why your home page ships code nobody opens

Code splitting cuts one big JavaScript file into parts that load on demand. Here's how it works, where it pays off, and where cutting actually hurts.

5 min read
GuidesSep 9, 2026

How to shrink your JavaScript bundle — 6 steps and the command to start with

Step by step: how to reduce JavaScript bundle size — measure it, find the heaviest package on a build map, split off what's rarely used, then re-measure.

6 min read
AI toolsSep 7, 2026

WebAssembly vs JavaScript — what's actually faster, and when

WebAssembly isn't always faster: the line runs through boundary crossings, not languages. Comparing WebAssembly and JavaScript, with a clear verdict.

5 min read
BasicsAug 16, 2026

What is a runtime — and why console.log is not part of JavaScript

A runtime is the environment that executes your code and gives it hands: files, network, output. Why one language can do different things in different places.

5 min read
BasicsJul 27, 2026

What is a Promise in JavaScript — and what Promise pending means

A Promise in JavaScript isn't the answer — it's a receipt for one. Why your console prints Promise pending, how await fixes it, and where beginners lose data.

5 min read
BasicsJul 18, 2026

What is Node.js — how JavaScript escaped the browser

Node.js is how you run JavaScript outside the browser: on a server, in the terminal, anywhere. Here's what Node.js is in plain words, and why you'll need it.

5 min read
AI toolsJul 8, 2026

TypeScript or JavaScript — what a beginner should pick, and the real difference

TypeScript is JavaScript that catches your typo before you run it. We compare on entry cost, errors and working with AI — and say plainly what a beginner should take.

6 min read
AI toolsJun 24, 2026

Python or JavaScript — which language should a beginner learn first

Python or JavaScript for a beginner? We compare entry cost, ecosystem, and AI — and give a straight answer on who should pick which, no fluff.

6 min read