Open In App
Related Articles

Underscore.js Collections Complete Reference

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

Underscore.js is a lightweight JavaScript library and not a complete framework that was written by Jeremy Ashkenas that provides utility functions for a variety of use cases in our day-to-day common programming tasks.

Underscore.js Collection functions are used on arrays, objects, and array-like objects such as arguments, NodeList, and similar other types of elements.

Function

Description

_.each()It returns the each element of the given list.
_.map()It produces a new array of values by mapping each value in list through transformation function.
_.reduce()It creates a single result from a given list of values.
_.reduceRight()It performs operations on each element from the right.
_.find()It looks at each element and returns the first occurrence of the element that satisfy the condition.
_.filter()It checks which elements in the passed array satisfy the condition.
_.where()It finds all the elements that matches the searching condition.
_.findWhere()It is used to have a list of all the elements that matches the given property.
_.reject()It gives the answer which does not match with the given condition.
_.every()It is used to test all the elements of the list can pass the given test.
_.some()It finds whether any value in the given list matches the given condition or not.
_.contains()It checks whether a particular item is given in the list of not.
_.invokes()It is used to perform certain actions on the elements of an array.
_.pluck()It is used when we need to extract a list of a given property.
_.max()It finds the minimum element from the list passed.
_.min()It finds the minimum element from the list passed.
_.sortBy()It sorts all the elements of the list in ascending order according to the function given to it as a parameter.
_.groupBy()It makes a collection of the elements in the array passed.
_.indexBy()It returns a key for each element in the list and then returns an object with an index of each item.
_.countBy()It sorts a list into groups and returns a count for the number of objects in each group.
_.shuffle()It is used to arrange a list of arrays in a random manner.
_.toArray()It creates a real array from the list of items that iterated over the elements.
_.size()It is used to find the size of an array.
_.partition()It is used to get an array as input and returns two arrays.

Last Updated : 01 Aug, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads