---
hide_title: false
hide_table_of_contents: false
pagination_next: null
pagination_prev: null
---
# Headers.forEach()

The **`Headers.forEach()`** method executes a callback function once per each key/value pair in the `Headers` object.

## Syntax

```js
// Arrow function
forEach((value, key) => { /* … */ })
forEach((value, key, object) => { /* … */ })

// Inline callback function
forEach(function (value, key) { /* … */ })
forEach(function (value, key, object) { /* … */ })
forEach(function (value, key) { /* … */ }, thisArg)
```

### Parameters

- `callbackFn`
  - : Function to execute for each entry in the map. It takes the following arguments:
    - `value`
      - : Value of the currently visited header entry.
    - `key`
      - : Name of the currently visited header entry.
    - `object`
      - : The Headers object being iterated.
- `thisArg` _**optional**_
  - : Value to use as `this` when executing `callback`.

### Return value

`undefined`.

## Description

The `Headers.forEach()` method executes the provided callback once for each key of the Headers which actually exist. It is not invoked for keys which have been deleted. However, it is executed for keys which are present but have the value undefined.
