What is the best way to Group an array of objects according to the keys in vanilla javascript, lets say I have 10000 records, this is the sample object
[
{
company: "TATA",
car: "TATA Indica",
color: "Blue"
},
{
company: "TATA",
car: "TATA Indica",
color: "Black"
},
{
company: "TATA",
car: "Safari",
color: "Blue"
},
{
"company": "Suzuki",
car: "",
color: ""
}
]
and the expected output is
{
"company": ["TATA", "Suzuki"],
"car": ["TATA Indica", "Safari"],
"color": ["Blue", "Black"]
}
company,car, orcolor?