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.

    Type Parameters

    • T extends any[]

    Parameters

    • predicate: ((...args: T) => boolean)

      The predicate to negate.

        • (...args): boolean
        • Parameters

          • Rest...args: T

          Returns boolean

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

    Returns the new negated function.

      • (...args): boolean
      • Parameters

        • Rest...args: T

        Returns boolean

    3.0.0

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

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