The Underscore.js documentation explains that the _.tap()
function "taps" into a method chain. http://underscorejs.org/#tap
I have trouble following their example:
_.chain([1,2,3,200])
.filter(function(num) { return num % 2 == 0; })
.tap(alert)
.map(function(num) { return num * num })
.value();
=> // [2, 200] (alerted)
=> [4, 40000]
What is the method chain in this context? I always thought of method chaining as the concept of chaining methods off of one another: object.foo().bar().baz()
.
I have seen examples using this method: module.exports = _.tap {}, (connectors) ->
, so does this "tap" into the object literal's method chain?