主题
flow
js
_.flow([funcs])
创建一个函数,返回使用所创建函数的 this
绑定调用给定函数的结果,其中每次连续调用都会提供前一次调用的返回值。
¥Creates a function that returns the result of invoking the given functions with the this
binding of the created function, where each successive invocation is supplied the return value of the previous.
新增于
¥Since
3.0.0
参数
¥Arguments
[funcs]
(...(函数|函数[])):受保护的方法是:¥
[funcs]
(...(Function|Function[])): The functions to invoke.
返回
¥Returns
(函数):返回新的复合函数。
¥(Function): Returns the new composite function.
示例
¥Example
js
function square(n) {
return n * n;
}
var addSquare = _.flow([_.add, square]);
addSquare(1, 2);
// => 9