I have an object. It looks like below:
[
{
\"name\":\"Display\",
\"group\":\"Technical detals\",
\"id\":\"60\",
\"value\":\"4\"
},
{
Try with something like this:
function groupBy(collection, property) {
var i = 0, val, index,
values = [], result = [];
for (; i < collection.length; i++) {
val = collection[i][property];
index = values.indexOf(val);
if (index > -1)
result[index].push(collection[i]);
else {
values.push(val);
result.push([collection[i]]);
}
}
return result;
}
var obj = groupBy(list, "group");
Keep in mind that Array.prototype.indexOf
isn't defined in IE8 and older, but there are common polyfills for that.