Web APIs

Headers.set()

Try the free JavaScript compiler

Sets or replaces a header value subject to the object guard.

Formal Syntax & Structure

javascript syntaxjavascript
headers.set(name, value)

Parameters & Attributes

NameTypeDescription
namestringHeader name.
valuestringHeader value.

Return Value

undefined

No return value.

Working Example

Example Snippetjavascript
(async () => {const h=new Headers({"X-Mode":"draft"});h.set("x-mode","ready");console.log(h.get("X-MODE"),h.has("x-other"));})()
JavaScript Reference