Collect.js count() Function Last Updated : 15 Oct, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report The count() function is used to count the number of collections in the element. Syntax: data.count()Parameters: This function does not accept any parameterReturn Value:Returns the count of the element in that collection.Example 1:Below examples illustrate the count() function in collect.js JavaScript // It is used to import collect.js library const collect = require('collect.js'); const num = [0 , 1 , 2 , 3 , 4, 5 , 6, 7, 8, 9]; const data = collect(num); const total = data.count(); console.log('Total number of elements are:', {total}); Output:Total number of elements are: { total: 10 } Example 2: JavaScript // It is used to import collect.js library const collect = require('collect.js'); const collection = collect([1, 2, 3, 4]); const x = collection.count(); console.log(`Total number of elements are : ${x}`); Output:Total number of elements are : 4 Comment More infoAdvertise with us Next Article Collect.js | flip() function A akhilsharma870 Follow Improve Article Tags : JavaScript Web Technologies Collect.js Similar Reads Collect.js first() Function The first() function gives the first value of the collection. It returns the first value or the first method returns the first element in the collection that passes a given condition. Syntax: data.first(e)Parameters: This function accepts a single parameter as mentioned above and described below:e: 1 min read Collect.js | flip() function The flip() function swaps the key with its corresponding value. In JavaScript, the array is first converted to a collection and then the function is applied to the collection. Syntax:Â data.flip() Parameters: This function does not accept any parameter. Return Value: Â Returns by flipping the collect 1 min read Collect.js | forPage() Function The forPage() function is used to return the value which is present at a particular page, this function take the page number as an argument and then returns the collection. In JavaScript, the array is first converted to a collection and then the function is applied to the collection. Syntax:Â data.f 1 min read Collect.js Introduction Collect.js is a JavaScript library for collecting data from tree-based structures. This library is used on JavaScript Array and Objects. Features: Some of the important features of Collect.js are: It is a fluent and convenient wrapper for working with arrays and objects.It provides us with different 2 min read Collect.js | push() Function The push() function is used to add a new value to the end of the collection. Â In JavaScript, the array is first converted to a collection and then the function is applied to the collection. Syntax:Â data.push(value) Parameters: This function accepts a single parameter as mentioned above and describe 1 min read Collect.js | chunk() Function The chunk() function breaks the collection to many small collections of the given size. Â In JavaScript, the array is first converted to a collection and then the function is applied to the collection. Syntax:Â data.chunk(x) Parameter: Â This function accepts a single parameter as mentioned above and 2 min read Like