The _.flatten() method in Lodash is used to flatten an array to a single level deep.
_.flatten(array)
This method accepts the following parameter:
array: This is the array to be flattened.This method returns a single level flattened array.
Let’s look at an example of the _.flatten() method in the code snippet below:
In the HTML tab:
lodash script.In the JavaScript tab:
_.flatten() method to flatten the array.We get an array in which all the values are flattened to a single level deep.