reject source npm

_.reject(collection, [predicate=_.identity])

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

Arguments

  1. collection (Array|Object)

    The collection to iterate over.

  2. [predicate=_.identity] (Function|Object|string)

    The function invoked per iteration.

Returns (Array)

Returns the new filtered array.

Example

var resolve = _.partial(_.map, _, 'user');

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

resolve( _.reject(users, function(o) { return !o.active; }) );
// => ['fred']

// using the `_.matches` callback shorthand
resolve( _.reject(users, { 'age': 40, 'active': true }) );
// => ['barney']

// using the `_.matchesProperty` callback shorthand
resolve( _.reject(users, ['active', false]) );
// => ['fred']

// using the `_.property` callback shorthand
resolve( _.reject(users, 'active') );
// => ['barney']