Why using `_.chain` is a mistake.
Izaak Schroeder
20714

Nice article! It’s true that `_.chain` implementation isn’t really the optimal solutions for chaining usage; and you have well explained some raisons for this. That said, with underscore-es there is the method `_.use` that can be also used to overcome this statut.

import _use from 'underscore-es/use';
import _initial from 'underscore-es/initial';
import _filter from 'underscore-es/filter';
import _union from 'underscore-es/union';
import _last from 'underscore-es/last';

function note (num) {return 'result: '+ (num + 10) + " / 20"}
var test = _use([1, 2, 3, 6, 9])
.do(_union, [1, 3, 11], [2, 6, 10, 14])
.do(_filter, (num) => num % 2 == 0)
.do(_initial)
.do(_last)
.do(note)
.value();
console.log( test );
// => result: 20 / 20