I want to compare many arrays and combine any that are identical:
A = [1,2,3];
B = [1,2,3];
C = [1,2,3];
D = [10,11,12];
E = [10,11,12];
F = [10,11,12];
G = [13,14];
H = [13,14];
If there are identical arrays then I'd like to create new arrays out of the identical ones:
I = [1,2,3];
J = [10,11,12];
K = [13,14];
Would I need to iterate through each element in one array against ALL of the elements in the other arrays?
for (var i in A) {
for (var j in B) {
if (A[i] == J[j]) {
// create new arrays
}
}
}
etc...
Then, create new arrays out of the matches? Sounds like a lot of overhead.
What's the best way to accomplish this?
Thanks!