URLSearchParams.has() — checking parameter presence
URLSearchParams.has() checks whether a parameter name or a name–value pair exists. It returns true or false without changing the parameters.
CKTIS / JavaScript
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
URLSearchParams.has() checks whether a parameter name or a name–value pair exists. It returns true or false without changing the parameters.
URLSearchParams.set() assigns one parameter value, removing duplicates or appending a missing name.
URLSearchParams.sort() orders parameters by name, mutating the object. Entries with identical names retain their original order.
Calling `params.toString()` returns the query parameters as text without a leading `?`. It uses form encoding while preserving order and repeated names.
ValidityState exposes read-only error flags for a form control. It distinguishes a missing required value, an invalid format, and text that is too short, with an important exception for values assigned by scripts.
ValidityState.valid is a read-only boolean property: it is true when none of the control's validation error flags are set.
Window exposes browser interfaces to a page: pixel information, relationships between windows, and resize and navigation events. Learn how Window differs from WindowProxy and why cross-origin access remains restricted.
Window.getComputedStyle reads an element's resolved CSS values after stylesheets have been applied. It returns a live, read-only object rather than a copy of inline declarations.
window.getSelection() exposes the current document's Selection object for reading and changing its selection.
The hashchange event on window reports a URL fragment change during same-document navigation. It provides the previous and new URLs, but calling pushState() or replaceState() does not itself fire it.
window.matchMedia tests a CSS media query from JavaScript. It returns a MediaQueryList with the current matches result and lets you observe changes in whether the query matches.
window.onerror handles error events reported to the window. For an ErrorEvent it receives five arguments, and returning true cancels default error reporting without resuming the interrupted code.
window.postMessage asynchronously sends data to a target window, including across origins. Prefer an exact `targetOrigin`; omitting it restricts delivery to the same origin. Receivers should validate the sender's origin, the sending window, and the payload structure.
Worker runs a dedicated script independently of the page interface. It returns results asynchronously through messages, without direct access to the page DOM.
Worker.onmessage receives worker replies, Worker.onerror reports worker failures, and Worker.onmessageerror handles unsuccessful deserialization of an incoming message. These three handlers belong to the Worker object in the code that created the worker.
The read-only WorkerGlobalScope.self property returns the current worker's global object. Use self for explicit access to its interfaces and event handling; it is neither the window object nor access to the page's DOM.
Worker.postMessage sends data to a dedicated worker through an asynchronous message channel. Data is structured-cloned, while an optional transfer list lets you transfer resources such as ArrayBuffer instead of copying them.
worker.terminate() stops a dedicated worker from code holding its Worker object. The method takes no arguments and returns undefined; it does not guarantee completion of the current task or execution of cleanup code.
WritableStream serializes writes of data chunks to a sink. Promises let producers control their pace.