JavaScript examples.
Bring websites to life.
JS Basics
console.log, let/const/var, template literals, semicolons, comments, typeof
JavaScript — Starter Programs
Minimal runnable programs to get you started with JavaScript. Admins can add more via the admin panel or the AI bulk-generate button.
Operators & Math
arithmetic, comparison, logical, ternary, nullish coalescing, optional chaining, spread/rest
Strings
indexing, slice, template literals, length, split/join, replace/replaceAll, regex basics
Arrays
literal, push/pop/shift/unshift, map/filter/reduce, find/some/every, sort with compare fn, destructuring
Objects
literal, dot vs bracket, Object.keys/values/entries, destructuring, spread, computed keys
Control Flow
if/else, switch, for, while, for...of, for...in, break/continue, labeled loops
Functions
declarations vs expressions, arrow funcs, default params, rest params, IIFE, closures, this binding
ES6+ Classes & Modules
class, constructor, methods, static, get/set, extends, super, import/export
Async / Promises
callbacks, Promise (resolve/reject/then/catch), async/await, Promise.all/allSettled, fetch demo
Mini Projects
FizzBuzz, palindrome check, Caesar cipher, debounce/throttle, click-counter, simple stopwatch, fetch + render JSON, form validator, light dark toggle, tiny router
Array Methods In Depth
map, filter, reduce, find/findIndex, some/every, flat/flatMap, sort with comparator, splice vs slice, fill, chaining pipelines
String Mastery
template literals, padStart/padEnd, split/join tricks, replaceAll with regex, case conversions, trim variants, char codes, localeCompare, repeat patterns, string reversal
Objects & Destructuring
nested destructuring, default values, rest/spread, computed keys, Object.entries/fromEntries, shallow vs deep clone, freeze/seal, property descriptors, optional chaining, nullish coalescing
Maps & Sets
Map basics, Map vs object, iterating maps, Set dedupe, set algebra, WeakMap use case, counting with Map, grouping with Map, LRU sketch, two-sum with Map
Dates & Times
Date basics, formatting with Intl, date math, countdown timer logic, age calculator, weekday names, ISO parsing, timezones with Intl, stopwatch with Date.now, relative time
Math & Numbers
rounding methods, random ranges, prime check, fibonacci, factorial, number formatting Intl, parseInt/parseFloat gotchas, toFixed pitfalls, BigInt, base conversions
Regular Expressions
test vs match, matchAll groups, named groups, replace with function, split with regex, validation email/phone, greedy vs lazy, flags, lookahead basics, sanitizing input
Closures & Scope
lexical scope, closure counters, module pattern, once function, memoize, private state, loop closure gotcha, currying, partial application, IIFE
Higher-Order Functions
functions as arguments, returning functions, compose, pipe, debounce, throttle, custom map implementation, custom filter, tap/logging, function factories
This & Binding
this in methods, arrow vs regular, call/apply/bind, losing this, constructor this, class field arrows, explicit binding patterns, borrowed methods, safe callbacks, bound counters
Prototypes & Classes
prototype chain, Object.create, constructor functions, class getters/setters, static members, inheritance with extends, super calls, instanceof, mixins, polymorphism demo
Error Handling
try/catch/finally, throw custom errors, Error subclasses, error cause, guarding JSON.parse, async errors, retry helper, validation errors, defensive defaults, safe wrappers
Async Deep Dive
promise chaining, Promise.all, allSettled, race/any, sequential vs parallel, timeout wrapper, cancellation flag, async queue, microtask demo, async error propagation
Generators & Iterators
iterator protocol, custom iterable, generator basics, infinite sequences, take helper, generator delegation, id generator, pagination iterator, lazy mapping, simple state machine
JSON & Data Transformation
parse/stringify options, reviver/replacer, deep clone via structuredClone, flatten nested JSON, groupBy, normalize array to map, pivot records, diff two objects, safe getters, CSV string to objects
Recursion
factorial, fibonacci memo, sum nested arrays, deep object search, tree traversal, permutations, flood-fill on grid, binary search recursive, nested menu depth, tower of hanoi
Sorting & Searching
custom comparators, multi-key sort, stable sort demo, binary search, quicksort, merge sort, counting occurrences, top-N selection, search in rotated array, fuzzy includes
Data Structures
stack, queue, linked list, binary tree insert/search, BFS, DFS, hash-map collisions concept, min-heap, graph adjacency list, trie sketch
Algorithm Challenges
two sum, anagram groups, longest unique substring, array chunk, matrix transpose, spiral order, balanced brackets, roman numerals, run-length encoding, move zeroes
Functional Patterns
immutability patterns, pure functions, reducers, maybe/optional pattern, result pattern, pipeline with reduce, point-free style, memo with WeakMap, freeze-based state, compose utilities
Timers & Scheduling
setTimeout basics, clearing timers, setInterval clock, debounce vs throttle, polling with backoff, task queue, batch scheduler, countdown, rate limiter, sleep helper
Events & Patterns
custom event emitter, once listeners, pub/sub, observer pattern, command pattern, state machine, undo stack, middleware chain, plugin registry, delegation logic
Modules & Organization
factory functions, dependency injection, singleton, config module, feature flags, constants enums, registry pattern, layered services, barrel pattern sketch, namespacing
Typed Thinking
runtime type checks, typeof/instanceof guards, schema validation by hand, assert helpers, exhaustive switch, safe parsing, defaults & coercion, invariant checks, duck typing, branded values sketch
Storage & URL Logic
localStorage wrapper, sessionStorage cart, URLSearchParams, URL parsing, query-string builder, cookie string parsing, history state sketch, base64 encode/decode, JSON storage versioning, expiring cach
Text & Formatting
Intl number/currency, plural rules, relative time formatter, slugify, truncate with ellipsis, word wrap, highlight matches, template renderer, simple markdown bold parser, word diff
Performance Patterns
memoization, lazy initialization, batching updates, early exit loops, Set membership vs includes, key lookup vs find, string builder pattern, avoiding re-computation, measuring with performance.now, o
Practical Utilities
deep get/set by path, uuid v4 generator, random picker, shuffle, range helper, clamp/lerp, retry with backoff, chunk processor, deep equal, debounce with leading edge
Capstone Challenges
expense tracker logic, quiz engine, shopping cart with discounts, bank ledger, inventory manager, flashcard scheduler, tic-tac-toe with winner check, URL shortener logic, mini state store, event-drive
Interview Warmups
reverse words in place, first non-repeating char, majority element, missing number, merge intervals, valid parentheses paths, product except self, max subarray, rotate matrix, staircase combinations
