_.tap

_.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

  1. value (*): The value to provide to interceptor.
  2. interceptor (Function): The function to invoke.

Returns

(*): Returns value.

Example

1
2
3
4
5
6
7
8
9
10
_([1, 2, 3])
 .tap(function(array) {
 
// Mutate input array.
 
   array.pop();
 })
 .reverse()
 .value();
// => [2, 1]
doc_Lodash
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.