Lodash - curryRight 方法
語法
_.curryRight(func, [arity=func.length])
該方法與 _.curry 類似,只不過向 func 應用引數的方式採用 _.partialRight 而不是 _.partial 形式。
引數
func (函式) − 要進行柯里化操作的函式。
[arity=func.length] (數字) − func 的元數。
輸出
(函式) − 返回新的柯里化函式。
示例
var _ = require('lodash');
var getArray = function(a, b, c) {
return [a, b, c];
};
var curried = _.curryRight(getArray);
console.log(curried(3)(2)(1));
console.log(curried(3, 2)(1));
console.log(curried(3, 2, 1));
將上述程式儲存在 tester.js 中。執行以下命令以執行此程式。
命令
\>node tester.js
輸出
[ 1, 2, 3 ] [ 1, 3, 2 ] [ 3, 2, 1 ]
lodash_function.htm
廣告