tap source

_.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 in order to perform operations on intermediate results within the chain.

Arguments

  1. value (*)

    The value to provide to interceptor.

  2. interceptor (Function)

    The function to invoke.

Returns (*)

Returns value.

Example

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