setTimeout — schedule a function once
setTimeout schedules a function to run once without blocking the current code. The delay does not guarantee an exact execution time, and the returned identifier lets you cancel the pending invocation.
CKTIS / Knowledge base
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
setTimeout schedules a function to run once without blocking the current code. The delay does not guarantee an exact execution time, and the returned identifier lets you cancel the pending invocation.
ShadowRoot represents the root of a Shadow DOM tree associated with a host element. It provides access to a component's internal structure. The open and closed modes differ in access through host.shadowRoot, but neither creates a security boundary.
ShadowRoot.append adds nodes and text at the end of a shadow tree. It is inherited from DocumentFragment rather than a separate implementation. Learn how nodes move, fragments become empty, and appendChild() differs.
Storage exposes string key–value pairs through localStorage and sessionStorage. Learn the difference between Storage.length, which counts entries, and Storage.key(index), which returns a key name rather than its value.
Storage.clear() synchronously removes every key–value pair from the selected Web Storage area. It takes no arguments and returns undefined. Be careful: it also deletes entries unrelated to your code.
Storage.getItem(key) synchronously reads text from localStorage or sessionStorage. It returns null when the key does not exist; an empty string is an existing value, not a missing entry.
The removeItem(key) method removes a specific key–value pair from localStorage or sessionStorage. It returns undefined; a missing key does not cause an error.
Storage.setItem stores text under a key in localStorage or sessionStorage, replacing the previous value. Writes can fail, so account for exceptions and storage access restrictions.
structuredClone() copies supported data structures, including nested objects and cycles. The transfer option moves resources instead of copying them; not every value type can be cloned.
TextDecoder converts bytes into text. Learn chunked decoding, error handling with fatal, and the meaning of ignoreBOM.
TextDecoderStream converts a byte stream into text, preserving decoder state between chunks.
TextEncoder converts text into UTF-8 bytes. Learn how encode() differs from encodeInto() and what the read and written counters mean.
TextEncoder.encode() encodes a JavaScript string as UTF-8 and returns a Uint8Array containing the resulting bytes. Call it on a TextEncoder instance; the byte count does not necessarily match the string length.
TextEncoderStream transforms text chunks into UTF-8 bytes while preserving surrogate pairs split across chunks.
TransformStream connects a writable side to a readable side. transform processes chunks, while flush can append final output before closure.
The unhandledrejection event reports a Promise rejection that remains unhandled when the browser reports it. It exposes the promise and rejection reason and is useful for diagnostics, not as a replacement for local error handling.
URL separates an address into components, resolves relative references, and lets you modify query parameters.
URL.hash reads and sets a URL fragment. Learn its encoding behavior and the distinction between empty and absent fragments.
URL.pathname lets you read or replace a URL's path without changing its query or fragment.
URLSearchParams reads and modifies query parameters, preserving repeated names and handling form-style encoding.
URL.searchParams exposes query parameters as a URLSearchParams object linked to the URL.
append(name, value) adds a pair at the end of the query parameters, preserving earlier values with the same name.
URLSearchParams.delete() removes every pair with a given name, or only pairs matching both the supplied name and value.
URLSearchParams.forEach calls a function for each parameter pair, preserving order and repeated names. The callback arguments are the value, key, and parameter object.