![]() |
VOOZH | about |
The values() method is used to return a new collection with the given keys reset to consecutive integers.
Syntax:
collect(array).values(key)
Parameters: The collect() method takes one argument that is converted into the collection and then values() method is applied to it. The values() method holds the key as a parameter.
Return Value: This method returns a new collection with the given keys reset to consecutive integers.
Below example illustrate the values() method in collect.js:
Example 1:
Output:
[ 'Geeks', 'Welcome', 'GFG', 'GeeksforGeeks' ]
Example 2:
Output:
[
{ name: 'Rahul', marks: 88 },
{ name: 'Aditya', marks: 78 },
{ name: 'Abhishek', marks: 87 }
]