Skip to content

Commit 1b0c6a4

Browse files
committed
remove duplicates
1 parent 50c6a80 commit 1b0c6a4

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

js/Array.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ if (index !== -1) {
7070
array.splice(index, 1, itemToBeInserted);
7171
}
7272

73+
// remove duplicates in another array
74+
const a = [0, 1];
75+
const b = [1, 2];
76+
// a and b can be the same
77+
const c = [...new Set([...a, ...b])]; // [0, 1, 2]
78+
79+
7380
// concat 2 arrays
7481
const arrayA = [1, 2, 3];
7582
const arrayB = [4, 5, 6];

0 commit comments

Comments
 (0)