Function reject

  • The opposite of filter this method returns the elements of collection that predicate does not return truthy for.

    Type Parameters

    • T

    Parameters

    • collection: Collection<T>

      The collection to iterate over.

    • predicate: CollectionIteratee<T>

      The function invoked per iteration.

    Returns T[]

    Returns the new filtered array.

    Since

    5.9.0

    See

    [[pull]], [[pullAll]], [[pullAllBy]], [[pullAllWith]], [[pullAt]], [[remove]], [[filter]]

    Example

    const users = [
    { 'user': 'barney', 'active': true },
    { 'user': 'fred', 'active': false }
    ]

    reject(users, ({ active }) => active)
    // => objects for ['fred']