主题
partialRight
js
_.partialRight(func, [partials])
此方法与 _.partial
类似,只是部分应用的参数会附加到它接收的参数中。
¥This method is like _.partial
except that partially applied arguments are appended to the arguments it receives.
_.partialRight.placeholder
值在单片构建中默认为 _
,可用作部分应用参数的占位符。
¥The _.partialRight.placeholder
value, which defaults to _
in monolithic builds, may be used as a placeholder for partially applied arguments.
注意:此方法不设置部分应用函数的 "length" 属性。
¥Note: This method doesn't set the "length" property of partially applied functions.
新增于
¥Since
1.0.0
参数
¥Arguments
func
(函数):部分应用参数的函数。¥
func
(Function): The function to partially apply arguments to.[partials]
(...*):要部分应用的参数。¥
[partials]
(...)*: The arguments to be partially applied.
返回
¥Returns
(函数):返回新的部分应用函数。
¥(Function): Returns the new partially applied function.
示例
¥Example
js
function greet(greeting, name) {
return greeting + ' ' + name;
}
var greetFred = _.partialRight(greet, 'fred');
greetFred('hi');
// => 'hi fred'
// Partially applied with placeholders.
var sayHelloTo = _.partialRight(greet, 'hello', _);
sayHelloTo('fred');
// => 'hello fred'