Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js group by

const groupBy = (arr, prop) =>
  arr.reduce((acc, val) => {
    ;(acc[val[prop]] = acc[val[prop]] || []).push(val)
    return acc
  }, {})
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #js #group
ADD COMMENT
Topic
Name
1+1 =