# ForEachCallback

## `ForEachCallback<Value, Payload>`

Represents a callback function of `.forEach()` method which is executed **once** for each element.

{% code title="foreach-callback.type.ts" %}

```typescript
type ForEachCallback<Value = any, Payload = object> = (
  result: boolean,
  value: Value,
  index?: number,
  array?: any[],
  payload?: Payload
) => void;
```

{% endcode %}

### Generic type variables

#### <mark style="color:green;">`Value`</mark>`=`<mark style="color:green;">`any`</mark>

A generic type variable `Value` determines the type of the [`value`](#value-value) parameter, by default [`any`](https://www.typescriptlang.org/docs/handbook/basic-types.html#any).

#### <mark style="color:green;">`Payload`</mark>`=`<mark style="color:green;">`object`</mark>

The shape of the optional [`payload`](#payload-payload) parameter, by default [`object`](https://www.typescriptlang.org/docs/handbook/basic-types.html#object).

### Parameters

#### `result: boolean`

The result of the check of a [`boolean`](https://www.typescriptlang.org/docs/handbook/basic-types.html#boolean) type.

#### `value: Value`

The **value** that has been checked of a generic type variable [`Value`](#value-any).

#### `index: number`

An optional [`number`](https://www.typescriptlang.org/docs/handbook/basic-types.html#number) of checked `array` element.

#### `array: any[]`

An optional `array` of [`any`](https://www.typescriptlang.org/docs/handbook/basic-types.html#any) type that **each** element is checked.

#### `payload?: Payload`

An optional [`object`](https://www.typescriptlang.org/docs/handbook/basic-types.html#object) of a generic type variable [`Payload`](#payload-object) to provide more data.

### Return type

The return value is void.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://type.angular-package.dev/type/foreachcallback.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
