4.17.11
3.10.1
2.4.2
1.3.1

_.tap(value, interceptor)

This method invokes interceptor and returns value. The interceptor is invoked with one argument; (value). The purpose of this method is to "tap into" a method chain sequence in order to modify intermediate results.

Since

0.1.0

Arguments

argument
value
interceptor
type
*
Function
description
The value to provide to `interceptor`.
The function to invoke.

Returns

(array)

Example

_([1, 2, 3])
  .tap(function (array) {
    // Mutate input array.
    array.pop();
  })
  .reverse()
  .value();
// => [2, 1]
_([1, 2, 3])
  .tap(function (array) {
    // Mutate input array.
    array.pop();
  })
  .reverse()
  .value();
// => [2, 1]