Headers: delete() メソッド
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2017.
メモ: この機能はウェブワーカー内で利用可能です。
delete()
は Headers
インターフェイスのメソッドで、現在の Headers
オブジェクトからヘッダーを削除します。
セキュリティ上の理由から、いくつかのヘッダーはユーザーエージェントでしか制御できません。これには、禁止ヘッダー名と禁止レスポンスヘッダー名があります。
構文
js
delete(name)
引数
name
-
Headers
オブジェクトから削除する HTTP ヘッダーの名前。
返値
なし (undefined
)。
例
空の Headers
オブジェクトの作成は簡単です。
js
const myHeaders = new Headers(); // Currently empty
Headers.append
を使用して、これにヘッダーを追加できます。
js
myHeaders.append("Content-Type", "image/jpeg");
myHeaders.get("Content-Type"); // Returns 'image/jpeg'
その後、再度削除することができます。
js
myHeaders.delete("Content-Type");
myHeaders.get("Content-Type"); // 削除されているため null を返す
仕様書
Specification |
---|
Fetch # ref-for-dom-headers-delete① |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
delete |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.