1let array1 = ['a','b','c'];
2let array2 = ['c','c','d','e'];
3let array3 = array1.concat(array2);
4array3 = [...new Set([...array1,...array2])]; // O(n)
1var initialData = [{
2 'ID': 1,
3 'FirstName': 'Sally'
4 },
5 {
6 'ID': 2,
7 'FirstName': 'Jim'
8 },
9 {
10 'ID': 3,
11 'FirstName': 'Bob'
12 }
13];
14
15var newData = [{
16 'ID': 2,
17 'FirstName': 'Jim'
18 },
19 {
20 'ID': 4,
21 'FirstName': 'Tom'
22 },
23 {
24 'ID': 5,
25 'FirstName': 'George'
26 }
27];
28
29var ids = new Set(initialData.map(d => d.ID));
30var merged = [...initialData, ...newData.filter(d => !ids.has(d.ID))];
1result[0] = 11
2result[1] = 22
3result[2] = 33
4result[3] = 11, 22
5result[4] = 11, 33
6result[5] = 22, 11
7result[6] = 22, 33
8result[7] = 33, 11
9result[8] = 33, 22
10result[9] = 11, 22, 33
11result[10] = 11, 33, 22
12result[11] = 22, 11, 33
13result[12] = 22, 33, 11
14And so on... (It's not necessary to have that order, i just want every possible variation (without repeating the same value on the index) on another array)
15