Skip to content

Is Object.groupBy working? #1291

Closed Answered by zloirock
Semigradsky asked this question in Q&A
Discussion options

You must be logged in to vote

console.log(Object.groupBy({}, ({ foo }) => foo)) fails because you pass a non-iterable object.

Works something like that:

console.log(Object.groupBy([{ foo: 1 }, { foo: 2 }], ({ foo }) => foo)); // => { 1: [{ foo: 1 }], 2: [{ foo: 2 }] }

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@zloirock
Comment options

@Semigradsky
Comment options

@zloirock
Comment options

@Semigradsky
Comment options

Answer selected by zloirock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants