JavaScript · Senior · Question 39 of 75

What does Object.groupBy(users, u => u.role) do?

Explanation

Object.groupBy (ES2024) replaces the typical reduce for grouping. The result is an object with a null prototype. If keys aren't strings, use Map.groupBy.

Further reading

Problem with a question

JavaScript · Senior · question 39

Test yourself

Take the JavaScript · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz