Skip to content

curryRight

js
_.curryRight(func, [arity=func.length])

此方法类似于 _.curry,只是参数以 _.partialRight 而不是 _.partial 的方式应用于 func

¥This method is like _.curry except that arguments are applied to func in the manner of _.partialRight instead of _.partial.

_.curryRight.placeholder 值在单片构建中​​默认为 _,可用作提供的参数的占位符。

¥The _.curryRight.placeholder value, which defaults to _ in monolithic builds, may be used as a placeholder for provided arguments.

注意:此方法不设置柯里化函数的 "length" 属性。

¥Note: This method doesn't set the "length" property of curried functions.

新增于

¥Since

3.0.0

参数

¥Arguments

  1. func (函数):要柯里化的函数。

    ¥func (Function): The function to curry.

  2. [arity=func.length] (数值):func 的元数。

    ¥[arity=func.length] (number): The arity of func.

返回

¥Returns

(函数):返回新的柯里化函数。

¥(Function): Returns the new curried function.

示例

¥Example

js
var abc = function(a, b, c) {
  return [a, b, c];
};

var curried = _.curryRight(abc);

curried(3)(2)(1);
// => [1, 2, 3]

curried(2, 3)(1);
// => [1, 2, 3]

curried(1, 2, 3);
// => [1, 2, 3]

// Curried with placeholders.
curried(3)(1, _)(2);
// => [1, 2, 3]

Lodash v4.17 中文网 - 粤ICP备13048890号