What Is Event Bubbling in JavaScript?
Event bubbling carries a DOM event from the clicked element up through its parents. See how it works, how to stop it and why delegation relies on it.
466 posts about JavaScript: questions with answers, tutorials and articles, newest first.
Event bubbling carries a DOM event from the clicked element up through its parents. See how it works, how to stop it and why delegation relies on it.
Use addEventListener to react to clicks, input and other events. Covers options, removal with AbortController, event delegation and accessible markup.
Call element.remove() to delete a node, use replaceChildren() to clear a container, and release listeners and references so removed elements are freed.
Use document.createElement, configure the node, then insert it with append, prepend or before. Covers fragments, templates, SVG and safe text handling.
getElementById looks up one element by id, while querySelector accepts any CSS selector. See when to use each, with examples and common pitfalls.
Use querySelector and querySelectorAll for CSS selectors and getElementById for ids. Learn the return types, live versus static results and common mistakes.
The Document Object Model is a live tree of nodes that JavaScript can read and modify. Learn how to select, update, create and listen to elements.
A mixin shares methods between unrelated JavaScript classes without a common parent. See Object.assign and subclass factory patterns, plus their pitfalls.
Instance methods act on one object through this; static methods belong to the class. See when to use each with modern ES2022 examples.
Use # private fields for real privacy in classes, or closures and module scope without classes. Symbol keys and underscores only hide data by convention.
Static methods belong to the class, not its instances. See the syntax, how this behaves, static fields, inheritance and common mistakes.
The super keyword calls a parent class constructor or method in JavaScript. Learn the rules, with examples for classes, statics and object literals.
A subclass can replace an inherited method by defining the same name and can reuse the parent version with super. See examples and pitfalls.
null is an intentional empty value and undefined is a missing one. Learn how they differ in comparisons, JSON and modern JavaScript operators.
Use Array.isArray(value) to check whether a JavaScript variable is an array. Compare it with instanceof, typed arrays, array-likes and TypeScript narrowing.
NaN is the number value JavaScript returns for invalid math. Learn what causes it, why it never equals itself and how to test for it safely.
Learn how to select and identify DOM elements in JavaScript with getElementById, querySelector and querySelectorAll, and how to find the element behind an event.
Use Number.isFinite() for usable numbers, or typeof plus Number.isNaN() when Infinity is fine. Includes numeric string checks and a comparison table.
A TypeScript function type is written (a: number) => string. See aliases, call signatures, optional parameters, generics, overloads and utility types.
A type of element can mean a JavaScript data type or a DOM element type. This guide covers typeof, instanceof, nodeType and input types.