I need some help figuring out how to get unique values from an array of objects in this format. I have reviewed several examples but none had the values of a key being an array. Thanks in advance for your advice.
I have a JS array with complex objects with some object values being arrays:
let array = [
{ key1: ["one","two","four"], key2: [1,2,4] },
{ key1: ["two","four","six"], key2: [2,4,6] },
{ key1: "nine", key2: 9 },
];
I want to get the unique values for all keys in the object (so it will support any structure) and output like this:
[
{
key1: ["one","two","four", "six", "nine"],
key2: [1,2,4,6,9]
}
]
{key1: ["one',"two","four","six","nine"], Key2: [1,2,3,6,9]}Also, it bothers me that the case ofkey1andKey1is different in your question.