![]() |
VOOZH | about |
Collect.js is a fluent and convenient wrapper for working with arrays and objects. The make() function creates a new collection instance.
Installation: Install the Collect.js module using the following command:
npm install --save collect.js
Syntax:
collection.make(user collection)
Parameters: This function takes only one parameter i.e. the user collection which is the collection defined by the user.
Return Value: This function returns the new collection object.
Example 1: Filename-index.js
Run the index.js file using the following command:
node index.js
Output:
[ 1, 2, 3, 4, 5 ] [ 1, 2, 3 ]
Example 2: Filename-index.js
Run the index.js file using the following command:
node index.js
Output:
Collection {
items: [ 'Monday', 'Tuesday', 'Thursday',
'Friday', 'Saturday', 'Sunday' ]
}
Reference: https://collect.js.org/api/make.html