Skip to main content
Version: 3.27.2

Headers.forEach()

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

Syntax

// 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.