I have an object with groups (as an example). Each group object contains one header id and multiple trigger ids.
I want to get an array of all the triggers of all groups without duplicates.
An example would be this:
const groups = {
group1: { header: 9, trigger: [10,11] },
group2: { header: 15, trigger: [11, 17] }
}
Currently, I am doing it like so:
const triggers = Array.from(groups, x => x.trigger);
This gives me the following result: [[10,11],[11,17]]
My plan is to get something like this: [10,11,17]. They don't have to be sorted but the duplicates (in this case 11) has to be removed. Is there any fast way of doing it? Otherwise I would loop through this array now and then concat to a new array but I think there is a faster and better solution.