將相同的輸入丟入,永遠都會回傳相同的輸出, 並且不對任何該函數以外的任何作用域產生影響。
有利重構(Refactor)
方便測試
平行化
利於建快取(Cache)
易與其他函數組合(Compose) 結合律
// 封裝陣列的 slice 讓它變為 functional 的 curry function。 // [1, 2, 3].slice(0, 2) var slice = undefined;
var slice = _.curry(function(start, end, xs){ return xs.slice(start, end);});
Return value is a function
Left direction
var fn = compose(f, g);
By chiao