JavaScript Knowledge Base

Concise guides on the JavaScript concepts used in exercises.

concepts
9 min read

JavaScript Set Methods: union, intersection, and difference

Learn JavaScript Set methods like union, intersection, difference, symmetricDifference, and subset checks with practical examples.

Latest update: Jun 9, 2026intermediate
concepts
9 min read

RegExp.escape in JavaScript

Learn how RegExp.escape safely inserts user text into dynamic regular expressions, and why hand-rolled escaping misses edge cases.

Latest update: Jun 9, 2026intermediate
concepts
9 min read

Optional Chaining and Nullish Coalescing in JavaScript

Learn optional chaining and nullish coalescing in JavaScript with nested objects, safe calls, fallbacks, and mistakes that hide bugs.

Latest update: Jun 1, 2026intermediate
concepts
8 min read

Object Destructuring in JavaScript

Learn object destructuring in JavaScript with renaming, defaults, function parameters, rest properties, and missing-property bugs.

Latest update: May 30, 2026intermediate
concepts
8 min read

addEventListener in JavaScript

Learn addEventListener in JavaScript with callback references, event objects, removeEventListener, one-time listeners, and the eager-handler bug.

Latest update: May 24, 2026beginner
concepts
8 min read

Object.keys, Object.values, and Object.entries: How to Choose

Choose Object.keys, Object.values, Object.entries, and Object.fromEntries by the shape of object data you need.

Latest update: May 20, 2026intermediate
concepts
6 min read

What Is Polyfilling in JavaScript?

Learn what polyfilling means in JavaScript, how it differs from transpiling, and why missing APIs need runtime fallbacks.

Latest update: May 17, 2026intermediate
concepts
8 min read

How Event Delegation Works in JavaScript

Learn how event delegation works in JavaScript, why bubbling makes it possible, and how to use target, currentTarget, and closest safely.

Latest update: May 15, 2026intermediate
concepts
8 min read

Event Bubbling in JavaScript Explained with target and currentTarget

Learn event bubbling in JavaScript, why parent listeners run after child clicks, and how target differs from currentTarget in real handlers.

Latest update: May 14, 2026intermediate
concepts
7 min read

querySelector vs querySelectorAll: What Is the Difference?

Learn when to use querySelector, when to use querySelectorAll, and why querySelectorAll returns a NodeList instead of an array.

Latest update: May 13, 2026beginner
concepts
8 min read

textContent vs innerHTML vs innerText in JavaScript

Learn when to use textContent, innerHTML, and innerText for DOM updates, plus the security and rendering traps behind each property.

Latest update: May 13, 2026beginner
concepts
7 min read

JavaScript Tasks vs Microtasks: Why Promises Run Before setTimeout

Learn JavaScript tasks vs microtasks, the event loop, Promise.then ordering, and why setTimeout(0) still waits.

Latest update: May 12, 2026intermediate
concepts
6 min read

Why Async Functions Always Return a Promise

Learn why every async function returns a Promise, how returned values and thrown errors behave, and how to call async functions correctly.

Latest update: May 11, 2026intermediate
concepts
9 min read

Higher-Order Functions in JavaScript

Learn higher-order functions in JavaScript with callbacks, returned functions, closures, array methods, and the mistakes that make them confusing.

Latest update: May 10, 2026intermediate
concepts
9 min read

JavaScript Prototypes and the Prototype Chain

Learn how JavaScript prototypes, property lookup, constructor functions, classes, instanceof, and prototype pollution actually work.

Latest update: May 10, 2026intermediate
concepts
9 min read

JavaScript Closures

Learn JavaScript closures with scope, private state, callbacks, loop bugs, async code, memory retention, and practical examples.

Latest update: May 9, 2026intermediate
concepts
6 min read

Truthy and Falsy Values in JavaScript

Learn the real JavaScript falsy values, why empty arrays are truthy, and how to avoid fallback bugs with || and ??.

Latest update: May 9, 2026beginner
concepts
8 min read

null vs undefined in JavaScript

Learn null vs undefined in JavaScript, where each value comes from, and how to write safer checks for missing data.

Latest update: May 8, 2026beginner
concepts
7 min read

JavaScript Spread Operator

Learn how the JavaScript spread operator copies arrays, merges objects, passes arguments, and where shallow copies cause bugs.

Latest update: May 8, 2026beginner
concepts
8 min read

When to Use some and every in JavaScript

Learn when to use some and every in JavaScript for boolean array checks, including short-circuiting, empty arrays, and validation rules.

Latest update: May 7, 2026beginner
concepts
7 min read

forEach vs map in JavaScript

Learn the real difference between forEach and map in JavaScript: side effects, return values, async callbacks, and when a loop is clearer.

Latest update: May 5, 2026beginner
concepts
8 min read

map vs filter vs find: How to Choose the Right Array Method

Learn how to choose between map, filter, and find by result shape, with examples for transformations, lists, one-record lookups, and common bugs.

Latest update: May 5, 2026beginner
concepts
7 min read

JavaScript Array Methods

Learn when to use map, filter, reduce, find, some, and every without turning simple array code into a mystery pipeline.

Latest update: May 4, 2026intermediate
concepts
8 min read

Off-by-One Errors in JavaScript Loops

Learn why off-by-one errors happen in JavaScript loops, how array length and indexes differ, and how to debug loop boundaries.

Latest update: May 4, 2026beginner
concepts
8 min read

break and continue in JavaScript

Learn how break and continue in JavaScript loops work, when to use each one, and the bugs they prevent or create.

Latest update: May 3, 2026beginner
concepts
8 min read

JavaScript while Loops

Learn JavaScript while loops with conditions, updates, sentinels, infinite-loop bugs, break, and when while beats for.

Latest update: May 3, 2026beginner
concepts
7 min read

JavaScript for...of Loop

Learn when to use the JavaScript for...of loop with arrays, strings, Maps, Sets, async code, break, continue, and Object.entries.

Latest update: May 2, 2026beginner
concepts
8 min read

JavaScript for Loops

Learn JavaScript for loops with counters, conditions, array indexes, off-by-one bugs, break, continue, and safer loop choices.

Latest update: May 2, 2026beginner
concepts
6 min read

JavaScript Switch Statements

Learn how JavaScript switch statements compare values, why break matters, and when switch is clearer than if...else.

Latest update: May 1, 2026beginner
concepts
5 min read

JavaScript Ternary Operator

Learn when the JavaScript ternary operator makes conditional values clearer, and when nested ternaries should become if or switch logic.

Latest update: May 1, 2026beginner
concepts
6 min read

JavaScript Arrow Functions

Learn how JavaScript arrow functions handle return values, this binding, arguments, and the cases where function syntax is still better.

Latest update: Apr 30, 2026intermediate
concepts
5 min read

JavaScript Template Literals

Learn how JavaScript template literals handle interpolation, multiline strings, tagged templates, and the escaping mistakes that cause bugs.

Latest update: Apr 30, 2026beginner
concepts
7 min read

Default Parameters in JavaScript

Learn how JavaScript default parameters handle undefined, falsy values, call-time expressions, destructuring, and optional arguments.

Latest update: Apr 29, 2026beginner
concepts
7 min read

Rest Parameters in JavaScript

Learn how JavaScript rest parameters collect arguments, replace arguments, differ from spread, and support flexible function APIs.

Latest update: Apr 29, 2026beginner
concepts
7 min read

Parameters and Arguments in JavaScript

Learn parameters and arguments in JavaScript, including positional matching, missing values, defaults, rest parameters, and object inputs.

Latest update: Apr 28, 2026beginner
concepts
6 min read

return vs console.log in JavaScript

Return vs console.log in JavaScript: learn what each one does, why logged values still return undefined, and when to use each.

Latest update: Apr 28, 2026beginner
concepts
9 min read

JavaScript Operators by Intent

Learn JavaScript operators by the job they do: calculate, compare, choose, update, combine, and avoid clever-looking bugs.

Latest update: Apr 27, 2026beginner
concepts
7 min read

JavaScript Comparison Operators

Learn how JavaScript comparison operators create booleans, why === beats ==, and where string, object, and NaN comparisons surprise people.

Latest update: Apr 26, 2026beginner
concepts
8 min read

JavaScript Logical Operators

Learn how JavaScript logical operators combine conditions, short circuit, return values, and differ from ?? for safe fallbacks.

Latest update: Apr 26, 2026beginner
concepts
8 min read

How typeof Works in JavaScript

Learn how typeof works in JavaScript, what strings it returns, why typeof null is object, and when Array.isArray or Number.isNaN is better.

Latest update: Apr 25, 2026beginner
concepts
7 min read

let vs const in JavaScript

Learn when to use let vs const in JavaScript, what const actually protects, and why reassignment is the real distinction.

Latest update: Apr 25, 2026beginner
concepts
8 min read

JavaScript Primitive Values Explained

Learn JavaScript primitive values, how they differ from objects, why strings have methods, and how null, undefined, symbols, and BigInts behave.

Latest update: Apr 24, 2026beginner
guides
8 min read

How to Trace JavaScript Code by Hand

Learn how to trace JavaScript code step by step with variables, loops, function calls, return values, array methods, and console output.

Latest update: Jun 2, 2026beginner
guides
8 min read

JSON.parse in JavaScript: Safe Parsing, Errors, and Fallbacks

Learn JSON.parse in JavaScript with SyntaxError handling, try/catch, fallback values, and the difference between parsing and validation.

Latest update: May 28, 2026intermediate
guides
8 min read

Form submit Events and preventDefault in JavaScript

Learn how form submit events work in JavaScript, why forms reload by default, and how preventDefault lets you validate and render UI.

Latest update: May 26, 2026beginner
guides
8 min read

classList in JavaScript: add, remove, toggle, and contains

Learn how to use classList in JavaScript to manage DOM state with CSS classes without overwriting existing classes.

Latest update: May 22, 2026beginner
guides
8 min read

How to Cancel a Fetch Request with AbortController

Use AbortController to cancel fetch requests, handle AbortError safely, and avoid stale responses in timeouts and search UIs.

Latest update: May 20, 2026intermediate
guides
8 min read

How to Handle fetch Errors Properly in JavaScript

Learn how to handle fetch errors with try/catch, response.ok, status codes, bad responses, and safe JSON parsing order.

Latest update: May 18, 2026intermediate
guides
7 min read

DOMContentLoaded vs defer: Why DOM Code Runs Too Early

Learn when to use DOMContentLoaded vs defer, why DOM queries run too early, and how script loading affects querySelector and event setup.

Latest update: May 16, 2026beginner
guides
8 min read

How to Store Objects in localStorage with JSON

Store objects in localStorage safely with JSON.stringify, JSON.parse, fallbacks, and the limits of browser storage.

Latest update: May 16, 2026beginner
guides
8 min read

Why querySelector Returns Null and How to Fix It

Learn why querySelector returns null, how to debug selectors and timing, and how to write safer DOM selection code.

Latest update: May 12, 2026beginner
guides
9 min read

When to Use Promise.all, Promise.allSettled, Promise.race, and Promise.any

Choose the right Promise combinator by whether you need every result, every outcome, the first settlement, or the first success.

Latest update: May 11, 2026intermediate
guides
8 min read

Why JavaScript sort() Mutates Arrays and How to Avoid It

Learn why JavaScript sort() mutates arrays, how to avoid accidental changes, and when to use toSorted, spread, or slice.

Latest update: May 7, 2026intermediate
guides
9 min read

How to Use reduce in JavaScript Without Getting Confused

Learn JavaScript reduce with a clear accumulator mental model, trace tables, initial values, and practical rules for when not to use it.

Latest update: May 6, 2026intermediate
guides
11 min read

JavaScript reduce Accumulator Patterns for Real Data

Use JavaScript reduce accumulator patterns for totals, counts, groups, indexes, averages, deduping, and safer real-world data summaries.

Latest update: May 6, 2026intermediate
guides
9 min read

JavaScript Operator Precedence Without Guessing

Learn JavaScript operator precedence without memorizing a chart, using parentheses, named steps, and high-risk expression patterns.

Latest update: Apr 27, 2026beginner