Lodash教程

Lodash curryRight method

语法

_.curryRight(func, [arity=func.length])
This method is like _.curry except that arguments are applied to func in the manner of _.partialRight instead of _.partial.

参数

func (Function) − The function to curry. [arity=func.length] (number) − The arity of func.

输出

(Function) − Returns the new curried function.

实例

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));
Save the above program in tester.js. Run the following command to execute this program.

Command

\>node tester.js

输出

[ 1, 2, 3 ]
[ 1, 3, 2 ]
[ 3, 2, 1 ]
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4