Function negate

  • 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.

    Parameters

    • predicate: any

      The predicate to negate.

    Returns ((...args) => boolean)

    Returns the new negated function.

      • (...args): boolean
      • Parameters

        • Rest ...args: any[]
          Rest

        Returns boolean

    Since

    5.13.0

    Example

    function isEven(n) {
    return n % 2 == 0
    }

    filter([1, 2, 3, 4, 5, 6], negate(isEven))
    // => [1, 3, 5]