JavaScript Tutorial with Examples.
JavaScript tutorial covering modern fundamentals, DOM manipulation, async patterns, Promises, fetch and the ES module system, each with real output.
Beginner
Start here — no prior experience needed
Introduction to JavaScript
Learn what JavaScript is, its history, how it powers the modern web, and why it's the most widely used programming language in the world.
Setting Up JavaScript Development Environment
Install Node.js and npm, configure VS Code with the right extensions, and run your first JavaScript program from the terminal.
Variables in JavaScript: var, let, and const
Understand the differences between var, let, and const — including hoisting, temporal dead zone, block scope, and when to use each one.
JavaScript Data Types
Explore JavaScript's seven primitive types and objects, understand typeof, type coercion, and learn how to check types reliably.
JavaScript Operators
Master JavaScript operators — arithmetic, comparison, logical, nullish coalescing, optional chaining, spread, and ternary — with real-world examples.
Control Flow in JavaScript
Learn how to direct your program's execution with if/else, switch, loops (for, while, for...of, for...in), break, continue, and labeled statements.
Functions in JavaScript
Master JavaScript functions — declarations, expressions, arrow functions, default and rest parameters, IIFEs, and first-class function patterns.
Working with Strings in JavaScript
Learn how to create, manipulate, and transform strings in JavaScript using template literals, built-in methods, and regular expressions.
Regular Expressions in JavaScript
Go beyond basic regex matching: why a shared /g regex's test() method alternates true and false on the same string, named capture groups with matchAll, replace() with a callback, and RegExp.escape for safely building patterns from user input.
Arrays in JavaScript
Learn JavaScript arrays — creation, functional methods like map/filter/reduce, destructuring, sorting, and common transformation patterns.
Objects in JavaScript
Learn JavaScript objects — literals, destructuring, spread/rest, Object utility methods, symbols, and patterns like config merging.
Map, Set, WeakMap, and WeakSet in JavaScript
Learn JavaScript's Map and Set: object-key coercion, insertion order, the new ES2025 Set operations, and why WeakMap and WeakSet can't be iterated.
JSON in JavaScript: stringify, parse, and What Gets Lost
Learn what JSON.stringify actually drops and rewrites — undefined and functions vanish, Date becomes a string, Map becomes {}, BigInt and circular references throw — and how toJSON and a reviver fix it.
Intermediate
For developers with core concepts down
Error Handling in JavaScript
Learn how to handle errors in JavaScript — try/catch/finally, built-in error types, custom error classes, rethrowing, and async error patterns.
Dates and Times in JavaScript: Date Pitfalls and Temporal
Date's setMonth silently rolls a short month into the next one. See Temporal.PlainDate clamp the same case instead, a DST change split +1 day from +24 hours, until() measure a real gap, and overflow: "reject" throw instead of guessing.
Object-Oriented Programming in JavaScript
Learn ES6 classes, inheritance, private fields, static members, getters/setters, and the mixin pattern for composing behavior in JavaScript.
Prototypes and Prototype Chain in JavaScript
Understand how JavaScript's prototype chain works, prototype-based inheritance, and how ES6 classes relate to prototypes under the hood.
Closures in JavaScript
Learn what closures are, how lexical scoping works, and how to use closures for private state, memoization, and module patterns.
this, call, apply, and bind in JavaScript
Learn how JavaScript's this is bound at call time, why detaching a method loses it, and how call, apply, and bind control it explicitly.
JavaScript Event Loop Explained
Understand how JavaScript's single-threaded event loop works, why microtasks run before macrotasks, and how to reason about async execution order.
Asynchronous JavaScript: Callbacks, Promises, and Async/Await
Master async JavaScript by understanding callbacks, Promises, and async/await — including error handling, parallel execution, and the full Promise API.
Iterators and Generators in JavaScript
Learn the iterator protocol behind for...of and spread, make your own objects iterable, and use generators for lazy pipelines and async iteration.
JavaScript Modules: ESM and CommonJS
Understand ES modules and CommonJS, their syntax differences, dynamic imports for code splitting, and how bundlers like Vite and webpack fit in.
DOM Manipulation in JavaScript
Learn how to select, create, modify, and remove DOM elements, handle events with delegation, and avoid common security pitfalls like XSS.
Browser Web APIs in JavaScript
A practical guide to the most useful browser Web APIs — Fetch, localStorage, Intersection Observer, Web Workers, WebSockets, and Geolocation.
Files, Streams, and the Command Line in Node.js
Learn Node.js CLI args, env vars, fs/promises, readline, and streams, including backpressure and error propagation through stream/promises pipeline.
Testing JavaScript with Jest and Vitest
Learn how to write reliable unit tests in JavaScript using Jest and Vitest — from basic assertions to mocking, async tests, and code coverage.
JavaScript Interview Preparation: Top 35 Questions
35 essential JavaScript interview questions with detailed answers and code examples — closures, hoisting, event loop, prototypes, async/await, and more.
Advanced
Production-grade patterns for experienced engineers
JavaScript Design Patterns
Runnable JavaScript design patterns — Module, Singleton, Observer, Factory and Command — each shown with real Node output and the problem it solves.
Proxy and Reflect in JavaScript
Learn how a JavaScript Proxy intercepts property access with get and set traps, why Reflect.set needs a receiver argument to forward correctly, and what Proxy.revocable throws once revoked.
JavaScript Performance Optimization
Practical JavaScript performance techniques — debounce, throttle, lazy loading, avoiding layout thrash, V8 optimization, and Web Workers.
JavaScript Security Best Practices
Learn how to protect JavaScript applications from XSS, CSRF, prototype pollution, insecure JWT handling, and other common web security vulnerabilities.
Also part of JavaScript
Taught in other topics. Each link opens the lesson in its home topic.