主题
negate
js
_.negate(predicate)创建一个否定谓词 func 结果的函数。func 谓词使用创建的函数的 this 绑定和参数来调用。
¥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.
新增于
¥Since
3.0.0
参数
¥Arguments
predicate(函数):谓词函数对。¥
predicate(Function): The predicate to negate.
返回
¥Returns
(函数):返回新的否定函数。
¥(Function): Returns the new negated function.
示例
¥Example
js
function isEven(n) {
return n % 2 == 0;
}
_.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));
// => [1, 3, 5]