Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to categorize a data in an array of object in javascript

var newData = data.reduce((obj, v, i)=> {

      obj[v.category] = obj[v.category] || [];
      obj[v.category].push(v);
      return obj;

    }, {});
    console.log(newData);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #categorize #data #array #object #javascript
ADD COMMENT
Topic
Name
6+9 =