• Invokes the given callback for each item in the given iterable.

    Example

    declare const map: Map<string, MyObject>;
    Array.from(map.values()).forEach(obj => obj.doSomething()); // creates a new array unnecessarily
    forEach(map.values(), obj => obj.doSomething()); // one-liner but no new array
    forEach(map.values(), withCounter((obj, i) => obj.doSomething(i)); // use withCounter for a kind of index

    Type Parameters

    Type Parameters

    • T

    Parameters

    • iterable: Iterable<T>

      any iterable

    • callback: ((item: T) => void)

      the callback to invoke per item

        • (item: T): void
        • Parameters

          • item: T

          Returns void

    Returns void

Generated using TypeDoc