- Lodash Tutorial
- Lodash - Home
- Lodash - Overview
- Lodash - Environment Setup
- Lodash - Array
- Lodash - Collection
- Lodash - Date
- Lodash - Function
- Lodash - Lang
- Lodash - Math
- Lodash - Number
- Lodash - Object
- Lodash - Seq
- Lodash - String
- Lodash - Util
- Lodash - Properties
- Lodash - Methods
- Lodash Useful Resources
- Lodash - Quick Guide
- Lodash - Useful Resources
- Lodash - Discussion
Lodash - tap method
Syntax
_.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.
Arguments
value (*) − The value to provide to interceptor.
interceptor (Function) − The function to invoke.
Output
(*) − Returns value.
Example
var _ = require('lodash'); var values = [1, 2, 3]; var result = _(values) .tap(function(array) { array.pop(); }) .reverse() .value(); console.log(result);
Save the above program in tester.js. Run the following command to execute this program.
Command
\>node tester.js
Output
[ 2, 1 ]
lodash_seq.htm
Advertisements