NewDash

    Function filter

    • Iterates over elements of collection, returning an array of all elements predicate returns truthy for. The predicate is invoked with three arguments: (value, index|key, collection).

      Note: Unlike remove, this method returns a new array.

      Type Parameters

      • T

      Parameters

      • collection: T[]

        The collection to iterate over.

      • Optionalpredicate: Predicate<T>

        The function invoked per iteration.

      Returns T[]

      Returns the new filtered array.

      5.0.0

      reject

      var users = [
      { 'user': 'barney', 'age': 36, 'active': true },
      { 'user': 'fred', 'age': 40, 'active': false }
      ];

      filter(users, function(o) { return !o.active; });
      // => objects for ['fred']

      // The `matches` iteratee shorthand.
      filter(users, { 'age': 36, 'active': true });
      // => objects for ['barney']

      // The `matchesProperty` iteratee shorthand.
      filter(users, ['active', false]);
      // => objects for ['fred']

      // The `property` iteratee shorthand.
      filter(users, 'active');
      // => objects for ['barney']
    • Iterates over elements of collection, returning an array of all elements predicate returns truthy for. The predicate is invoked with three arguments: (value, index|key, collection).

      Note: Unlike remove, this method returns a new array.

      Type Parameters

      • T

      Parameters

      • collection: T[]

        The collection to iterate over.

      • Optionalpredicate: any

        The function invoked per iteration.

      Returns T[]

      Returns the new filtered array.

      5.0.0

      reject

      var users = [
      { 'user': 'barney', 'age': 36, 'active': true },
      { 'user': 'fred', 'age': 40, 'active': false }
      ];

      filter(users, function(o) { return !o.active; });
      // => objects for ['fred']

      // The `matches` iteratee shorthand.
      filter(users, { 'age': 36, 'active': true });
      // => objects for ['barney']

      // The `matchesProperty` iteratee shorthand.
      filter(users, ['active', false]);
      // => objects for ['fred']

      // The `property` iteratee shorthand.
      filter(users, 'active');
      // => objects for ['barney']
    MMNEPVFCICPMFPCPTTAAATR