So in this section I will be going just over some array methods in lodash, and briefly cover some of the collection methods as well later in this post.
The _.chunk method is a lodash array method that can be used to break a linear array into an array of arrays of a given length. The need to do this comes up now and then and the chunk method helps to make quick work of this, and allow me to move on with a project rather than writing this usual suspect from scratch.
The compact method as well as the lodash filter, and native array filter methods will all return a new array rather than mutating an array in place.
The zip method takes two or more arrays and zips theme together into a single array. I can not say that I find myself using this one that often in actual projects, but it is an example of an array method that does not show up in the array prototype.
The lodash fine collection method can be used to find a single value in an array of values. It can also be used to find an Object in an array of objects also. The lodash find method is useful for fining a single value in an array, but it is not the same thing as sorting, filtering, reducing, or mapping. In some cases I might want to find the top five of something for example, so for that I would want to sort and slice.
The lodash map method is another method in lodash where the native counterpart Array.map only works with arrays. The lodash map method can map values to an array or any collection object with the value that is returned by the function that it is given.
If you enjoyed this post you might want to check out my main post on lodash in general.