@mirei/ts-collections
    Preparing search index...

    Function forEach

    • Executes the provided callback for every element in the sequence.

      Type Parameters

      • TElement

        Type of elements within the source iterable.

      Parameters

      • source: Iterable<TElement>

        The source iterable.

      • action: IndexedAction<TElement>

        Callback invoked for each element; receives the element and its zero-based index.

      Returns void

      Enumeration starts immediately. Avoid mutating the underlying collection while iterating.

      const numbers = [1, 2, 3];
      forEach(numbers, (x, i) => console.log(`Index ${i}: ${x}`));
      // Index 0: 1
      // Index 1: 2
      // Index 2: 3