Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Concatenation of arrays and remove duplicates
/*
* Concatenation of arrays and remove duplicates from all of them
* @arguments Arrays
*/
concatArrays = (...arrays) => {
var children = [].concat(...arrays);
var returnArray = [...new Set(children)];
return returnArray;
}
let arr1 = ['a', 'c', 'd'];
let arr2 = ['d', 'g', 'g', 'e'];
let arr3 = ['d', 'f', 'e', 'a'];
console.log(concatArrays(arr1, arr2, arr3)); // ["a", "c", "d", "g", "d", "f"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.