Last updated 5 years ago
Was this helpful?
语法:
_.negate(predicate)
源代码链接:
npm包链接:
描述:
创建一个针对断言函数func结果取反的函数。func断言函数被调用的时候,this绑定到创建的函数,并传入对应参数。
func
this
开始版本:3.0.0
参数:
predicate (Function): 需要对结果取反的函数。
predicate (Function)
返回值:
(Function): 返回一个新的取反函数。
(Function)
例子:
function isEven(n) { return n % 2 == 0; } _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven)); // => [1, 3, 5]