Collect.js | collapse() Method
The collapse() method convert collection of arrays into a single flat array.
- Collect.js can be installed via NPM:
npm install --save collect.js
- You can also use CDN of collect.js
Parameters: The collect() takes one argument that is converted into the collection and then collapse() function is applied on it, which will convert into a single flat array.
Return Value: Returns an array.
Example 1: Here collect = require(‘collect.js’) is used to import the collect.js library into the file.