web api instance method
Headers: delete() method
Available in workers
The delete() method of the Headers
interface deletes a header from the current Headers object.
For security reasons, some headers can only be controlled by the user agent. These headers include the forbidden request headers and forbidden response header names.
Syntax
delete(name)
Parameters
name- : The name of the HTTP header you want to delete from the
Headersobject.
- : The name of the HTTP header you want to delete from the
Return value
None (undefined).
Examples
Creating an empty Headers object is simple:
const myHeaders = new Headers(); // Currently empty
You could add a header to this using append:
myHeaders.append("Content-Type", "image/jpeg");
myHeaders.get("Content-Type"); // Returns 'image/jpeg'
You can then delete it again:
myHeaders.delete("Content-Type");
myHeaders.get("Content-Type"); // Returns null, as it has been deleted
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.