Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

Knowledge base — JavaScript

Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.

Entries: 1003

JavaScript

Document.body — accessing the document's body element

Document.body is a Web API property accessed as document.body. It returns a body element, a legacy frameset element, or null. Assignment replaces the entire element, not just its contents.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

document.createDocumentFragment() — creating a DOM fragment

document.createDocumentFragment() creates an empty DOM fragment. You can collect nodes in it and then move them into a parent without adding an extra wrapper element.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

document.createElement — creating a DOM element

document.createElement creates a new DOM element with the specified name. It does not automatically insert it into the document.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

document.createTextNode() — creating a text node

document.createTextNode(data) creates a Text node containing the supplied content without interpreting it as markup.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

Document.documentElement — the document's root element

Document.documentElement returns the document's root element or null. The property is read-only, but the element itself can be modified.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

DOMContentLoaded — DOM tree readiness

DOMContentLoaded signals that HTML parsing and deferred script execution have finished. Use it to initialize an interface without waiting for the entire page to load.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

DocumentFragment — grouping DOM nodes

DocumentFragment groups DOM nodes without a wrapper element. Inserting the fragment moves its children and leaves it empty.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

document.getElementById — find an element by ID

document.getElementById(elementId) returns the element with the specified ID or null. Matching is case-sensitive and searches the document’s descendants.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

Document.hidden — reading document visibility

Document.hidden is a read-only property indicating whether the browser considers the document hidden. Observe visibilitychange to track changes.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

document.querySelector — the first matching element

document.querySelector(selectors) finds the first element matching a CSS selector. It returns an element or null; an invalid selector throws an exception.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

document.querySelectorAll — all matching elements

Finds elements using CSS selectors and returns a static NodeList, including an empty list when nothing matches.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

Document.readyState — document loading state

Document.readyState describes the document's loading stage: loading, interactive, or complete. Checking this property helps initialize DOM-related code even when a script loads too late to receive DOMContentLoaded.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

Document.title — reading and changing the document title

Document.title reads and sets a document's title. Reading it normalizes ASCII whitespace.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

visibilitychange — document visibility changes

The visibilitychange event reports a change in document visibility. Read the current state from document.visibilityState.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

DataCloneError DOMException — data cloning failure

DataCloneError is the name of a DOMException indicating that data cannot be cloned. Learn a typical cause in structuredClone(), how to recognize the error, and why an unsupported value differs from a supported circular reference.

Intermediate · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

DOMRect.height — rectangle height

DOMRect.height is a rectangle's writable vertical dimension. It can be negative and affects the computed top and bottom edges.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

DOMRect.top — top-edge coordinate

`DOMRect.top` is a read-only property that returns the coordinate of a rectangle’s top edge. Even with a negative height, floating-point rounding can make the result equal to `y`.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

DOMRect.width — rectangle width

DOMRect.width is a writable instance property describing a rectangle's width. It holds a floating-point number and permits negative values. Do not confuse it with the read-only DOMRectReadOnly.width property.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

DOMStringList and membership checks with contains()

DOMStringList is a list of strings exposed by some Web APIs that you do not modify directly. Its contains() method checks whether a supplied string belongs to the list and returns a boolean. A typical use is checking object store names in IndexedDB.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

DOMTokenList.add() — adding tokens

DOMTokenList.add() adds tokens, such as classes through element.classList, skipping duplicates and validating arguments.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

DOMTokenList.contains — checking token membership

DOMTokenList.contains(token) reports whether a list contains the exact token, for example a CSS class in element.classList.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

DOMTokenList — managing tokens through classList

DOMTokenList represents a set of tokens, such as an element's classes exposed through classList. Learn to add, remove, toggle, and check tokens without manually processing the text of the class attribute.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

DOMTokenList.remove() — removing tokens

DOMTokenList.remove() removes specified tokens, such as element classes through classList. Learn how multiple arguments, missing tokens, and invalid values are handled.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
JavaScript

DOMTokenList.toggle() — toggling a token

DOMTokenList.toggle() toggles a token's presence or forces it with force. It returns whether the token is present after the call.

Basic · ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support