VOOZH about

URL: https://www.geeksforgeeks.org/javascript/collect-js-all-method/

⇱ Collect.js | all() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Collect.js | all() Method

Last Updated : 16 Aug, 2021

The all() method is used to return the underlying array or object represented by the collection. The JavaScript array is first transformed into a collection and then the function is applied to the collection.

Syntax: 

collect(array).all()

Parameters: The method does not accept any parameter.

Return Value: Returns an array or object.

Below examples illustrate the all() method in JavaScript:

Example 1: Here collect = require(‘collect.js’) is used to import the collect.js library into the file.

Output:

Result : [1, 2, 3]

Example 2:

Output:

Result : { first: 'GeeksforGeeks', second: 'Collect.js' }

Reference: https://collect.js.org/api/all.html
 

Comment
Article Tags: