<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@csstools/css-parser-algorithms](./css-parser-algorithms.md) &gt; [ContainerNodeBaseClass](./css-parser-algorithms.containernodebaseclass.md) &gt; [forEach](./css-parser-algorithms.containernodebaseclass.foreach.md)

## ContainerNodeBaseClass.forEach() method

Iterates over each item in the `value` array of the current node.

**Signature:**

```typescript
forEach<T extends Record<string, unknown>, U extends ContainerNode>(this: U, cb: (entry: {
        node: ComponentValue;
        parent: ContainerNode;
        state?: T;
    }, index: number | string) => boolean | void, state?: T): false | undefined;
```

## Parameters

<table><thead><tr><th>

Parameter


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

this


</td><td>

U


</td><td>


</td></tr>
<tr><td>

cb


</td><td>

(entry: { node: [ComponentValue](./css-parser-algorithms.componentvalue.md)<!-- -->; parent: [ContainerNode](./css-parser-algorithms.containernode.md)<!-- -->; state?: T; }, index: number \| string) =&gt; boolean \| void


</td><td>

The callback function to execute for each item. The function receives an object containing the current node (`node`<!-- -->), its parent (`parent`<!-- -->), and an optional `state` object. A second parameter is the index of the current node. The function can return `false` to stop the iteration.


</td></tr>
<tr><td>

state


</td><td>

T


</td><td>

_(Optional)_ An optional state object that can be used to pass additional information to the callback function. The state object is cloned for each iteration. This means that changes to the state object are not reflected in the next iteration.


</td></tr>
</tbody></table>

**Returns:**

false \| undefined

`false` if the iteration was halted, `undefined` otherwise.

