Collect.js flatten() Method
Collect.js is a wrapper library for working with arrays and objects which is dependency-free and easy to use. The flatten() method is used to flatten a multi-dimensional collection into a single dimensional collection and returns the flatten single dimensional collection elements.
Parameters: The collect() method takes one argument that is converted into the collection and then flatten() method is applied on it.
Return Value: This method returns the flatten single dimensional collection elements.
Example 1: Below example illustrates the flatten() method in collect.js
[ 'Rahul', 98, 'Aditya', 96, 'Abhishek', 80 ]
[ 'Geeks', 'GFG', 'GeeksforGeeks', 10, 20, 30, 40, 50 ]