_.at(collection, [index])

Creates an array of elements from the specified indexes, or keys, of the collection. Indexes may be specified as individual arguments or as arrays of indexes.

Arguments

  1. collection (Array|Object|string): The collection to iterate over.
  2. [index] (…(number|number[]|string|string[]): The indexes of collection to retrieve, specified as individual indexes or arrays of indexes.

Returns

(Array): Returns a new array of elements corresponding to the provided indexes.

Example

  1. _.at(['a', 'b', 'c', 'd', 'e'], [0, 2, 4]);
  2. // => ['a', 'c', 'e']
  3. _.at(['fred', 'barney', 'pebbles'], 0, 2);
  4. // => ['fred', 'pebbles']

_.contains(collection, target, [fromIndex=0])

Checks if a given value is present in a collection using strict equality for comparisons, i.e. ===. If fromIndex is negative, it is used as the offset from the end of the collection.

Aliases

_.include

Arguments

  1. collection (Array|Object|string): The collection to iterate over.
  2. target (*): The value to check for.
  3. [fromIndex=0] (number): The index to search from.

Returns

(boolean): Returns true if the target element is found, else false.

Example

  1. _.contains([1, 2, 3], 1);
  2. // => true
  3. _.contains([1, 2, 3], 1, 2);
  4. // => false
  5. _.contains({ 'name': 'fred', 'age': 40 }, 'fred');
  6. // => true
  7. _.contains('pebbles', 'eb');
  8. // => true

_.countBy(collection, [callback=identity], [thisArg])

Creates an object composed of keys generated from the results of running each element of collection through the callback. The corresponding value of each key is the number of times the key was returned by the callback. The callback is bound to thisArg and invoked with three arguments; (value, index|key, collection).

If a property name is provided for callback the created “.pluck” style callback will return the property value of the given element.

If an object is provided for callback the created “
.where” style callback will return true for elements that have the properties of the given object, else false.

Arguments

  1. collection (Array|Object|string): The collection to iterate over.
  2. [callback=identity] (Function|Object|string): The function called per iteration. If a property name or object is provided it will be used to create a “.pluck” or “.where” style callback, respectively.
  3. [thisArg] (*): The this binding of callback.

Returns

(Object): Returns the composed aggregate object.

Example

  1. _.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); });
  2. // => { '4': 1, '6': 2 }
  3. _.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math);
  4. // => { '4': 1, '6': 2 }
  5. _.countBy(['one', 'two', 'three'], 'length');
  6. // => { '3': 2, '5': 1 }

_.every(collection, [callback=identity], [thisArg])

Checks if the given callback returns truey value for all elements of a collection. The callback is bound to thisArg and invoked with three arguments; (value, index|key, collection).

If a property name is provided for callback the created “.pluck” style callback will return the property value of the given element.

If an object is provided for callback the created “
.where” style callback will return true for elements that have the properties of the given object, else false.

Aliases

_.all

Arguments

  1. collection (Array|Object|string): The collection to iterate over.
  2. [callback=identity] (Function|Object|string): The function called per iteration. If a property name or object is provided it will be used to create a “.pluck” or “.where” style callback, respectively.
  3. [thisArg] (*): The this binding of callback.

Returns

(boolean): Returns true if all elements passed the callback check, else false.

Example

  1. _.every([true, 1, null, 'yes']);
  2. // => false
  3. var characters = [
  4. { 'name': 'barney', 'age': 36 },
  5. { 'name': 'fred', 'age': 40 }
  6. ];
  7. // using "_.pluck" callback shorthand
  8. _.every(characters, 'age');
  9. // => true
  10. // using "_.where" callback shorthand
  11. _.every(characters, { 'age': 36 });
  12. // => false

_.filter(collection, [callback=identity], [thisArg])

Iterates over elements of a collection, returning an array of all elements the callback returns truey for. The callback is bound to thisArg and invoked with three arguments; (value, index|key, collection).

If a property name is provided for callback the created “.pluck” style callback will return the property value of the given element.

If an object is provided for callback the created “
.where” style callback will return true for elements that have the properties of the given object, else false.

Aliases

_.select

Arguments

  1. collection (Array|Object|string): The collection to iterate over.
  2. [callback=identity] (Function|Object|string): The function called per iteration. If a property name or object is provided it will be used to create a “.pluck” or “.where” style callback, respectively.
  3. [thisArg] (*): The this binding of callback.

Returns

(Array): Returns a new array of elements that passed the callback check.

Example

  1. var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
  2. // => [2, 4, 6]
  3. var characters = [
  4. { 'name': 'barney', 'age': 36, 'blocked': false },
  5. { 'name': 'fred', 'age': 40, 'blocked': true }
  6. ];
  7. // using "_.pluck" callback shorthand
  8. _.filter(characters, 'blocked');
  9. // => [{ 'name': 'fred', 'age': 40, 'blocked': true }]
  10. // using "_.where" callback shorthand
  11. _.filter(characters, { 'age': 36 });
  12. // => [{ 'name': 'barney', 'age': 36, 'blocked': false }]

_.find(collection, [callback=identity], [thisArg])

Iterates over elements of a collection, returning the first element that the callback returns truey for. The callback is bound to thisArg and invoked with three arguments; (value, index|key, collection).

If a property name is provided for callback the created “.pluck” style callback will return the property value of the given element.

If an object is provided for callback the created “
.where” style callback will return true for elements that have the properties of the given object, else false.

Aliases

.detect, .findWhere

Arguments

  1. collection (Array|Object|string): The collection to iterate over.
  2. [callback=identity] (Function|Object|string): The function called per iteration. If a property name or object is provided it will be used to create a “.pluck” or “.where” style callback, respectively.
  3. [thisArg] (*): The this binding of callback.

Returns

(*): Returns the found element, else undefined.

Example

  1. var characters = [
  2. { 'name': 'barney', 'age': 36, 'blocked': false },
  3. { 'name': 'fred', 'age': 40, 'blocked': true },
  4. { 'name': 'pebbles', 'age': 1, 'blocked': false }
  5. ];
  6. _.find(characters, function(chr) {
  7. return chr.age < 40;
  8. });
  9. // => { 'name': 'barney', 'age': 36, 'blocked': false }
  10. // using "_.where" callback shorthand
  11. _.find(characters, { 'age': 1 });
  12. // => { 'name': 'pebbles', 'age': 1, 'blocked': false }
  13. // using "_.pluck" callback shorthand
  14. _.find(characters, 'blocked');
  15. // => { 'name': 'fred', 'age': 40, 'blocked': true }

_.findLast(collection, [callback=identity], [thisArg])

This method is like _.find except that it iterates over elements of a collection from right to left.

Arguments

  1. collection (Array|Object|string): The collection to iterate over.
  2. [callback=identity] (Function|Object|string): The function called per iteration. If a property name or object is provided it will be used to create a “.pluck” or “.where” style callback, respectively.
  3. [thisArg] (*): The this binding of callback.

Returns

(*): Returns the found element, else undefined.

Example

  1. _.findLast([1, 2, 3, 4], function(num) {
  2. return num % 2 == 1;
  3. });
  4. // => 3

_.forEach(collection, [callback=identity], [thisArg])

Iterates over elements of a collection, executing the callback for each element. The callback is bound to thisArg and invoked with three arguments; (value, index|key, collection). Callbacks may exit iteration early by explicitly returning false.

Note: As with other “Collections” methods, objects with a length property are iterated like arrays. To avoid this behavior _.forIn or _.forOwn may be used for object iteration.

Aliases

_.each

Arguments

  1. collection (Array|Object|string): The collection to iterate over.
  2. [callback=identity] (Function): The function called per iteration.
  3. [thisArg] (*): The this binding of callback.

Returns

(Array|Object|string): Returns collection.

Example

  1. _([1, 2, 3]).forEach(function(num) { console.log(num); }).join(',');
  2. // => logs each number and returns '1,2,3'
  3. _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); });
  4. // => logs each number and returns the object (property order is not guaranteed across environments)

_.forEachRight(collection, [callback=identity], [thisArg])

This method is like _.forEach except that it iterates over elements of a collection from right to left.

Aliases

_.eachRight

Arguments

  1. collection (Array|Object|string): The collection to iterate over.
  2. [callback=identity] (Function): The function called per iteration.
  3. [thisArg] (*): The this binding of callback.

Returns

(Array|Object|string): Returns collection.

Example

  1. _([1, 2, 3]).forEachRight(function(num) { console.log(num); }).join(',');
  2. // => logs each number from right to left and returns '3,2,1'

_.groupBy(collection, [callback=identity], [thisArg])

Creates an object composed of keys generated from the results of running each element of a collection through the callback. The corresponding value of each key is an array of the elements responsible for generating the key. The callback is bound to thisArg and invoked with three arguments; (value, index|key, collection).

If a property name is provided for callback the created “.pluck” style callback will return the property value of the given element.

If an object is provided for callback the created “
.where” style callback will return true for elements that have the properties of the given object, else false

Arguments

  1. collection (Array|Object|string): The collection to iterate over.
  2. [callback=identity] (Function|Object|string): The function called per iteration. If a property name or object is provided it will be used to create a “.pluck” or “.where” style callback, respectively.
  3. [thisArg] (*): The this binding of callback.

Returns

(Object): Returns the composed aggregate object.

Example

  1. _.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); });
  2. // => { '4': [4.2], '6': [6.1, 6.4] }
  3. _.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math);
  4. // => { '4': [4.2], '6': [6.1, 6.4] }
  5. // using "_.pluck" callback shorthand
  6. _.groupBy(['one', 'two', 'three'], 'length');
  7. // => { '3': ['one', 'two'], '5': ['three'] }

_.indexBy(collection, [callback=identity], [thisArg])

Creates an object composed of keys generated from the results of running each element of the collection through the given callback. The corresponding value of each key is the last element responsible for generating the key. The callback is bound to thisArg and invoked with three arguments; (value, index|key, collection).

If a property name is provided for callback the created “.pluck” style callback will return the property value of the given element.

If an object is provided for callback the created “
.where” style callback will return true for elements that have the properties of the given object, else false.

Arguments

  1. collection (Array|Object|string): The collection to iterate over.
  2. [callback=identity] (Function|Object|string): The function called per iteration. If a property name or object is provided it will be used to create a “.pluck” or “.where” style callback, respectively.
  3. [thisArg] (*): The this binding of callback.

Returns

(Object): Returns the composed aggregate object.

Example

  1. var keys = [
  2. { 'dir': 'left', 'code': 97 },
  3. { 'dir': 'right', 'code': 100 }
  4. ];
  5. _.indexBy(keys, 'dir');
  6. // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
  7. _.indexBy(keys, function(key) { return String.fromCharCode(key.code); });
  8. // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
  9. _.indexBy(characters, function(key) { this.fromCharCode(key.code); }, String);
  10. // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }

_.invoke(collection, methodName, [arg])

Invokes the method named by methodName on each element in the collection returning an array of the results of each invoked method. Additional arguments will be provided to each invoked method. If methodName is a function it will be invoked for, and this bound to, each element in the collection.

Arguments

  1. collection (Array|Object|string): The collection to iterate over.
  2. methodName (Function|string): The name of the method to invoke or the function invoked per iteration.
  3. [arg] (…*): Arguments to invoke the method with.

Returns

(Array): Returns a new array of the results of each invoked method.

Example

  1. _.invoke([[5, 1, 7], [3, 2, 1]], 'sort');
  2. // => [[1, 5, 7], [1, 2, 3]]
  3. _.invoke([123, 456], String.prototype.split, '');
  4. // => [['1', '2', '3'], ['4', '5', '6']]

_.map(collection, [callback=identity], [thisArg])

Creates an array of values by running each element in the collection through the callback. The callback is bound to thisArg and invoked with three arguments; (value, index|key, collection).

If a property name is provided for callback the created “.pluck” style callback will return the property value of the given element.

If an object is provided for callback the created “
.where” style callback will return true for elements that have the properties of the given object, else false.

Aliases

_.collect

Arguments

  1. collection (Array|Object|string): The collection to iterate over.
  2. [callback=identity] (Function|Object|string): The function called per iteration. If a property name or object is provided it will be used to create a “.pluck” or “.where” style callback, respectively.
  3. [thisArg] (*): The this binding of callback.

Returns

(Array): Returns a new array of the results of each callback execution.

Example

  1. _.map([1, 2, 3], function(num) { return num * 3; });
  2. // => [3, 6, 9]
  3. _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; });
  4. // => [3, 6, 9] (property order is not guaranteed across environments)
  5. var characters = [
  6. { 'name': 'barney', 'age': 36 },
  7. { 'name': 'fred', 'age': 40 }
  8. ];
  9. // using "_.pluck" callback shorthand
  10. _.map(characters, 'name');
  11. // => ['barney', 'fred']

_.max(collection, [callback=identity], [thisArg])

Retrieves the maximum value of a collection. If the collection is empty or falsey -Infinity is returned. If a callback is provided it will be executed for each value in the collection to generate the criterion by which the value is ranked. The callback is bound to thisArg and invoked with three arguments; (value, index, collection).

If a property name is provided for callback the created “.pluck” style callback will return the property value of the given element.

If an object is provided for callback the created “
.where” style callback will return true for elements that have the properties of the given object, else false.

Arguments

  1. collection (Array|Object|string): The collection to iterate over.
  2. [callback=identity] (Function|Object|string): The function called per iteration. If a property name or object is provided it will be used to create a “.pluck” or “.where” style callback, respectively.
  3. [thisArg] (*): The this binding of callback.

Returns

(*): Returns the maximum value.

Example

  1. _.max([4, 2, 8, 6]);
  2. // => 8
  3. var characters = [
  4. { 'name': 'barney', 'age': 36 },
  5. { 'name': 'fred', 'age': 40 }
  6. ];
  7. _.max(characters, function(chr) { return chr.age; });
  8. // => { 'name': 'fred', 'age': 40 };
  9. // using "_.pluck" callback shorthand
  10. _.max(characters, 'age');
  11. // => { 'name': 'fred', 'age': 40 };

_.min(collection, [callback=identity], [thisArg])

Retrieves the minimum value of a collection. If the collection is empty or falsey Infinity is returned. If a callback is provided it will be executed for each value in the collection to generate the criterion by which the value is ranked. The callback is bound to thisArg and invoked with three arguments; (value, index, collection).

If a property name is provided for callback the created “.pluck” style callback will return the property value of the given element.

If an object is provided for callback the created “
.where” style callback will return true for elements that have the properties of the given object, else false.

Arguments

  1. collection (Array|Object|string): The collection to iterate over.
  2. [callback=identity] (Function|Object|string): The function called per iteration. If a property name or object is provided it will be used to create a “.pluck” or “.where” style callback, respectively.
  3. [thisArg] (*): The this binding of callback.

Returns

(*): Returns the minimum value.

Example

  1. _.min([4, 2, 8, 6]);
  2. // => 2
  3. var characters = [
  4. { 'name': 'barney', 'age': 36 },
  5. { 'name': 'fred', 'age': 40 }
  6. ];
  7. _.min(characters, function(chr) { return chr.age; });
  8. // => { 'name': 'barney', 'age': 36 };
  9. // using "_.pluck" callback shorthand
  10. _.min(characters, 'age');
  11. // => { 'name': 'barney', 'age': 36 };

_.pluck(collection, property)

Retrieves the value of a specified property from all elements in the collection.

Arguments

  1. collection (Array|Object|string): The collection to iterate over.
  2. property (string): The name of the property to pluck.

Returns

(Array): Returns a new array of property values.

Example

  1. var characters = [
  2. { 'name': 'barney', 'age': 36 },
  3. { 'name': 'fred', 'age': 40 }
  4. ];
  5. _.pluck(characters, 'name');
  6. // => ['barney', 'fred']

_.reduce(collection, [callback=identity], [accumulator], [thisArg])

Reduces a collection to a value which is the accumulated result of running each element in the collection through the callback, where each successive callback execution consumes the return value of the previous execution. If accumulator is not provided the first element of the collection will be used as the initial accumulator value. The callback is bound to thisArg and invoked with four arguments; (accumulator, value, index|key, collection).

Aliases

.foldl, .inject

Arguments

  1. collection (Array|Object|string): The collection to iterate over.
  2. [callback=identity] (Function): The function called per iteration.
  3. [accumulator] (*): Initial value of the accumulator.
  4. [thisArg] (*): The this binding of callback.

Returns

(*): Returns the accumulated value.

Example

  1. var sum = _.reduce([1, 2, 3], function(sum, num) {
  2. return sum + num;
  3. });
  4. // => 6
  5. var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) {
  6. result[key] = num * 3;
  7. return result;
  8. }, {});
  9. // => { 'a': 3, 'b': 6, 'c': 9 }

_.reduceRight(collection, [callback=identity], [accumulator], [thisArg])

This method is like _.reduce except that it iterates over elements of a collection from right to left.

Aliases

_.foldr

Arguments

  1. collection (Array|Object|string): The collection to iterate over.
  2. [callback=identity] (Function): The function called per iteration.
  3. [accumulator] (*): Initial value of the accumulator.
  4. [thisArg] (*): The this binding of callback.

Returns

(*): Returns the accumulated value.

Example

  1. var list = [[0, 1], [2, 3], [4, 5]];
  2. var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []);
  3. // => [4, 5, 2, 3, 0, 1]

_.reject(collection, [callback=identity], [thisArg])

The opposite of _.filter this method returns the elements of a collection that the callback does not return truey for.

If a property name is provided for callback the created “.pluck” style callback will return the property value of the given element.

If an object is provided for callback the created “
.where” style callback will return true for elements that have the properties of the given object, else false.

Arguments

  1. collection (Array|Object|string): The collection to iterate over.
  2. [callback=identity] (Function|Object|string): The function called per iteration. If a property name or object is provided it will be used to create a “.pluck” or “.where” style callback, respectively.
  3. [thisArg] (*): The this binding of callback.

Returns

(Array): Returns a new array of elements that failed the callback check.

Example

  1. var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
  2. // => [1, 3, 5]
  3. var characters = [
  4. { 'name': 'barney', 'age': 36, 'blocked': false },
  5. { 'name': 'fred', 'age': 40, 'blocked': true }
  6. ];
  7. // using "_.pluck" callback shorthand
  8. _.reject(characters, 'blocked');
  9. // => [{ 'name': 'barney', 'age': 36, 'blocked': false }]
  10. // using "_.where" callback shorthand
  11. _.reject(characters, { 'age': 36 });
  12. // => [{ 'name': 'fred', 'age': 40, 'blocked': true }]

_.sample(collection, [n])

Retrieves a random element or n random elements from a collection.

Arguments

  1. collection (Array|Object|string): The collection to sample.
  2. [n] (number): The number of elements to sample.

Returns

(Array): Returns the random sample(s) of collection.

Example

  1. _.sample([1, 2, 3, 4]);
  2. // => 2
  3. _.sample([1, 2, 3, 4], 2);
  4. // => [3, 1]

_.shuffle(collection)

Creates an array of shuffled values, using a version of the Fisher-Yates shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle.

Arguments

  1. collection (Array|Object|string): The collection to shuffle.

Returns

(Array): Returns a new shuffled collection.

Example

  1. _.shuffle([1, 2, 3, 4, 5, 6]);
  2. // => [4, 1, 6, 3, 5, 2]

_.size(collection)

Gets the size of the collection by returning collection.length for arrays and array-like objects or the number of own enumerable properties for objects.

Arguments

  1. collection (Array|Object|string): The collection to inspect.

Returns

(number): Returns collection.length or number of own enumerable properties.

Example

  1. _.size([1, 2]);
  2. // => 2
  3. _.size({ 'one': 1, 'two': 2, 'three': 3 });
  4. // => 3
  5. _.size('pebbles');
  6. // => 7

_.some(collection, [callback=identity], [thisArg])

Checks if the callback returns a truey value for any element of a collection. The function returns as soon as it finds a passing value and does not iterate over the entire collection. The callback is bound to thisArg and invoked with three arguments; (value, index|key, collection).

If a property name is provided for callback the created “.pluck” style callback will return the property value of the given element.

If an object is provided for callback the created “
.where” style callback will return true for elements that have the properties of the given object, else false.

Aliases

_.any

Arguments

  1. collection (Array|Object|string): The collection to iterate over.
  2. [callback=identity] (Function|Object|string): The function called per iteration. If a property name or object is provided it will be used to create a “.pluck” or “.where” style callback, respectively.
  3. [thisArg] (*): The this binding of callback.

Returns

(boolean): Returns true if any element passed the callback check, else false.

Example

  1. _.some([null, 0, 'yes', false], Boolean);
  2. // => true
  3. var characters = [
  4. { 'name': 'barney', 'age': 36, 'blocked': false },
  5. { 'name': 'fred', 'age': 40, 'blocked': true }
  6. ];
  7. // using "_.pluck" callback shorthand
  8. _.some(characters, 'blocked');
  9. // => true
  10. // using "_.where" callback shorthand
  11. _.some(characters, { 'age': 1 });
  12. // => false

_.sortBy(collection, [callback=identity], [thisArg])

Creates an array of elements, sorted in ascending order by the results of running each element in a collection through the callback. This method performs a stable sort, that is, it will preserve the original sort order of equal elements. The callback is bound to thisArg and invoked with three arguments; (value, index|key, collection).

If a property name is provided for callback the created “.pluck” style callback will return the property value of the given element.

If an array of property names is provided for callback the collection will be sorted by each property value.

If an object is provided for callback the created “
.where” style callback will return true for elements that have the properties of the given object, else false.

Arguments

  1. collection (Array|Object|string): The collection to iterate over.
  2. [callback=identity] (Array|Function|Object|string): The function called per iteration. If a property name or object is provided it will be used to create a “.pluck” or “.where” style callback, respectively.
  3. [thisArg] (*): The this binding of callback.

Returns

(Array): Returns a new array of sorted elements.

Example

  1. _.sortBy([1, 2, 3], function(num) { return Math.sin(num); });
  2. // => [3, 1, 2]
  3. _.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math);
  4. // => [3, 1, 2]
  5. var characters = [
  6. { 'name': 'barney', 'age': 36 },
  7. { 'name': 'fred', 'age': 40 },
  8. { 'name': 'barney', 'age': 26 },
  9. { 'name': 'fred', 'age': 30 }
  10. ];
  11. // using "_.pluck" callback shorthand
  12. _.map(_.sortBy(characters, 'age'), _.values);
  13. // => [['barney', 26], ['fred', 30], ['barney', 36], ['fred', 40]]
  14. // sorting by multiple properties
  15. _.map(_.sortBy(characters, ['name', 'age']), _.values);
  16. // = > [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]]

_.toArray(collection)

Converts the collection to an array.

Arguments

  1. collection (Array|Object|string): The collection to convert.

Returns

(Array): Returns the new converted array.

Example

  1. (function() { return _.toArray(arguments).slice(1); })(1, 2, 3, 4);
  2. // => [2, 3, 4]

_.where(collection, props)

Performs a deep comparison of each element in a collection to the given properties object, returning an array of all elements that have equivalent property values.

Arguments

  1. collection (Array|Object|string): The collection to iterate over.
  2. props (Object): The object of property values to filter by.

Returns

(Array): Returns a new array of elements that have the given properties.

Example

  1. var characters = [
  2. { 'name': 'barney', 'age': 36, 'pets': ['hoppy'] },
  3. { 'name': 'fred', 'age': 40, 'pets': ['baby puss', 'dino'] }
  4. ];
  5. _.where(characters, { 'age': 36 });
  6. // => [{ 'name': 'barney', 'age': 36, 'pets': ['hoppy'] }]
  7. _.where(characters, { 'pets': ['dino'] });
  8. // => [{ 'name': 'fred', 'age': 40, 'pets': ['baby puss', 'dino'] }]