Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

if property is same group javscript

var xobj = [
    { role:"Organize Admin", role_id:"id1", permission_name:"View All Users",active: "true" },
    { role:"Organize Admin", role_id:"id1", permission_name:"Create users", active: "true" },
    { role:"Organize Admin", role_id:"id1", permission_name:"Edit users", active: "true" },
    { role:"System Admin", role_id:"id2", permission_name:"Edit users", active: "true" },
    { role:"System Admin", role_id:"id2", permission_name:"Edit users", active: "true" },
];
var groups = {};
xobj.forEach(obj => {	
    if(!groups.hasOwnProperty(obj.role_id)){
        groups[obj.role_id] = [];
    }
    groups[obj.role_id].push(obj);
})
console.log(groups)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #property #group #javscript
ADD COMMENT
Topic
Name
4+9 =