forEach<T>(array: T[],callback?: () => unknown,): T[]
Iterates over each element of the array invoking the provided callback function for each element.
array: T[]
- The array to iterate over.
- The function invoked for each element. The callback function receives three arguments:
- 'value': The current element being processed in the array.
- 'index': The index of the current element being processed in the array.
- 'array': The array 'forEach' was called upon.
T[]
Returns the original array.
forEach<T>(array: readonly T[],callback?: () => unknown,): readonly T[]
Iterates over each element of the array invoking the provided callback function for each element.
array: readonly T[]
- The array to iterate over.
- The function invoked for each element. The callback function receives three arguments:
- 'value': The current element being processed in the array.
- 'index': The index of the current element being processed in the array.
- 'array': The array 'forEach' was called upon.
readonly T[]
Returns the original array.
forEach<T extends >(): T
Iterates over each element of the array invoking the provided callback function for each element.
string: T
- The string to iterate over
- The function invoked for each char. The callback function receives three arguments:
- 'char': The current char being processed in the string.
- 'index': The index of the current char being processed in the string.
- 'string': The string 'forEach' was called upon.
Returns the original string.
forEach<T>(array: ArrayLike<T>,callback?: () => unknown,): ArrayLike<T>
Iterates over each element of the array invoking the provided callback function for each element.
array: ArrayLike<T>
- The array to iterate over.
- The function invoked for each element. The callback function receives three arguments:
- 'value': The current element being processed in the array.
- 'index': The index of the current element being processed in the array.
- 'array': The array 'forEach' was called upon.
ArrayLike<T>
Returns the original array.
forEach<T extends >(object: T,callback?: (value: T[keyof T],key: keyof T,object: T,) => unknown,): T
Iterates over each element of the object invoking the provided callback function for each property.
object: T
- The object to iterate over.
- The function invoked for each property. The callback function receives three arguments:
- 'value': The current property being processed in the object.
- 'key': The key of the current property being processed in the object.
- 'object': The object 'forEach' was called upon.
Returns the original object.