Created
December 12, 2019 19:29
-
-
Save wickkidd/dfc0f9d9553f06687a356c4841424c57 to your computer and use it in GitHub Desktop.
esNext groupBy()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
groupBy(array, property) { | |
return array.reduce(function(rv, x) { | |
(rv[x[property]] = rv[x[property]] || []).push(x) | |
return rv | |
}, {}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment