VOOZH about

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

⇱ Collect.js pluck() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Collect.js pluck() Method

Last Updated : 30 Nov, 2020

The pluck() method is used to return all the values from the given key.

Syntax:

collect(array).pluck(key)

Parameters: The collect() method takes one argument that is converted into the collection and then pluck() method is applied on it. The pluck() method holds the key as parameter.

Return Value: This method returns all values from the given key.

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

Example 1:

Output:

[ 'Rahul', 'Aditya', 'Abhishek' ]

Example 2:

Output:

{ '25-10-96': 'Aditya', '16-08-94': 'Abhishek' }
Comment
Article Tags: