VOOZH about

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

⇱ Collect.js macro() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Collect.js macro() Method

Last Updated : 26 Nov, 2020

The macro() method is used to register a custom method. This method used the custom function.

Syntax:

collect(array).macro()

Parameters: The collect() method takes one argument that is converted into the collection and then macro() method is applied on it.

Return Value: This method returns the collection keys.

Below example illustrate the macro() method in collect.js:

Example 1:

Output:

Collection {
 items: [
 true, false, false,
 true, true, false,
 true, true, false,
 true
 ]
}

Example 2:

Output:

Collection { items: [ 'GFG', 'GEEKS', 'GEEKSFORGEEKS' ] }
Comment
Article Tags: