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