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 lodash _.compact method can be used to quickly remove false values from an array. It is a quick convenience method for just using _.filter to do the same thing.
So when it comes to doing the opposite of _.chunk and quickly turning an array of arrays back into a simple linear array there is the _.flatten method as well.
The zip method takes two or more arrays and zips theme together.
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.