Skip to content

Instantly share code, notes, and snippets.

@suissa
Last active July 15, 2024 20:48
Show Gist options
  • Save suissa/4653e18db66174f5aab768bdb583804c to your computer and use it in GitHub Desktop.
Save suissa/4653e18db66174f5aab768bdb583804c to your computer and use it in GitHub Desktop.
Group by bem facinho
const groupBy = (xs, key) => xs.reduce((rv, x) => ({
...rv, [x[key]]: [...(rv[x[key]] || []), x]
}), {});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment