VOOZH about

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

⇱ Collect.js keys() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Collect.js keys() Method

Last Updated : 27 Nov, 2020

The keys() method is used to return all of the collection's keys.

Syntax:

collect(array).keys()

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

Return Value: This method returns the collection keys.

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

Example 1:

Output:

[ 'name', 'dob', 'section', 'score' ]

Example 2:

Output:

[ 0, 1, 2, 3 ]
Comment
Article Tags: