forNext
Generic types: | T |
Allows us to iterate over an array using for/next instead of using an iterator (forEach for example) which can be 10x slower. This provides the same benefit as forEach but without the performance hit.
Presentation
function forNext (
array: T[],
callback: (item: T, index: number, array: T[]) => void,
): void;
Returns
void
Parameters
Name | Type | Description |
---|---|---|
array | T[] | the array we want to iterate over |
callback | (item: T, index: number, array: T[]) => void | the callback function to call for each item in the array. |