Executes a callback with the provided array and returns the array. Useful for side-effects (e.g., logging) in the middle of a function chain.
The array to tap into
The callback to execute
The original array
tap([1, 2, 3], console.log).map(x => x * 2); Copy
tap([1, 2, 3], console.log).map(x => x * 2);
Executes a callback with the provided array and returns the array. Useful for side-effects (e.g., logging) in the middle of a function chain.