Lodash _.thru() Method
The _.thru() method of Sequence in lodash is similar to _.tap() method and the only difference is that it returns the outcome of the interceptor. Moreover, this method is mainly used to “pass thru” values in a method chain sequence by replacing intermediate results.
Parameters: This method accepts two parameters as mentioned above and described below:
- value: It is the value to be given to the interceptor.
- interceptor: It is the function to be called.
Return Value: This method returns the result of the interceptor.
[ 144 ]
[ 'GfG' ]
[ [ 'G', 'f', 'g' ] ]
Here, the output is reversed as reverse() method is used above in order to reverse the order of the value stated.