Iterates through an iterable and optionally performs a side effect on each value. Unlike other generator functions, this doesn't yield values but simply consumes them.
Type of elements in the iterable
Optional
Optional function to call on each value
A function that consumes an iterable and returns void
// Log each value in an arrayconsume(console.log)([1, 2, 3, 4])// Logs: 1, 2, 3, 4 Copy
// Log each value in an arrayconsume(console.log)([1, 2, 3, 4])// Logs: 1, 2, 3, 4
// Simply exhaust an iterable without doing anything with the valuesconsume()([1, 2, 3, 4]) Copy
// Simply exhaust an iterable without doing anything with the valuesconsume()([1, 2, 3, 4])
Iterates through an iterable and optionally performs a side effect on each value. Unlike other generator functions, this doesn't yield values but simply consumes them.