阅读(4724) (0)

Lodash _.negate

2021-09-22 08:42:28 更新

_.negate(predicate)

创建一个针对断言函数 func 结果取反的函数。 func 断言函数被调用的时候,this 绑定到创建的函数,并传入对应参数。

添加版本

3.0.0

参数

  1. predicate (Function): 需要对结果取反的函数。

返回

(Function): 返回一个新的取反函数。

例子

function isEven(n) {  return n % 2 == 0;} _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
// => [1, 3, 5]