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.
function isEven(n) {
return n % 2 == 0
}
filter([1, 2, 3, 4, 5, 6], negate(isEven))
// => [1, 3, 5]
| Name | Type | Attribute | Description |
|---|---|---|---|
| predicate | The predicate to negate. |
{
"comment": "/**\r\n * Creates a function that negates the result of the predicate `func`. The\r\n * `func` predicate is invoked with the `this` binding and arguments of the\r\n * created function.\r\n *\r\n * @since 3.0.0\r\n * @category Function\r\n * @param {Function} predicate The predicate to negate.\r\n * @returns {Function} Returns the new negated function.\r\n * @example\r\n *\r\n * function isEven(n) {\r\n * return n % 2 == 0\r\n * }\r\n *\r\n * filter([1, 2, 3, 4, 5, 6], negate(isEven))\r\n * // => [1, 3, 5]\r\n */",
"meta": {
"range": [
487,
688
],
"filename": "negate.js",
"lineno": 19,
"path": "C:\\Users\\beaujeup\\projects\\jsdoc-template\\examples\\lodash\\lodash-repo",
"code": {
"id": "astnode100006411",
"name": "negate",
"type": "FunctionDeclaration",
"paramnames": [
"predicate"
]
},
"vars": {
"": null
}
},
"description": "Creates a function that negates the result of the predicate `func`. The\r`func` predicate is invoked with the `this` binding and arguments of the\rcreated function.",
"since": "3.0.0",
"tags": [
{
"originalTitle": "category",
"title": "category",
"text": "Function",
"value": "Function"
}
],
"params": [
{
"type": {
"names": [
"function"
]
},
"description": "The predicate to negate.",
"name": "predicate"
}
],
"returns": [
{
"type": {
"names": [
"function"
]
},
"description": "Returns the new negated function."
}
],
"examples": [
"function isEven(n) {\r return n % 2 == 0\r}\r\rfilter([1, 2, 3, 4, 5, 6], negate(isEven))\r// => [1, 3, 5]"
],
"name": "negate",
"longname": "negate",
"kind": "function",
"scope": "global",
"___id": "T000002R000600",
"___s": true,
"filepath": "negate.js"
}