I have an array of objects and am looking for the most efficient way with es6 to group them based on the material_id
var data=[
{material_id:1, item:'test'},
{material_id:1, item:'test2'},
{material_id:2, item:'test2'},
]
So at the end i want to get
var final_data = [
1,2
]
THat is the id's from the grouped material_id
SO i have tried this but am stuck on how to proceed further
let final_data = [];
data.forEach(item=>{
//stuck here
})
I have checked on This question but it doesnt seem to show a grouping