Date

“Function” Methods

_.negate(predicate)

source npm package

Creates a function that negates the result of the predicate func. The func predicate is invoked with the this binding and arguments of the created function.

引入版本

3.0.0

参数
predicate (Function) : The predicate to negate.

返回值
(Function) : Returns the new negated function.

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