Skip to content
Nate
Stephens

Remove Duplicate Values in an Array

Single Array

const arr = ['foo', 'bar', 'baz', 'foo'];

const noDuplicates = [...new Set(arr)];
// ['foo', 'bar', 'baz']

Multiple Arrays

const arr1 = ['foo', 'bar', 'baz', 'foo'];
const arr2 = ['baz', 'bingo'];

const noDuplicates = [...new Set([...arr1, ...arr2])];
//['foo', 'bar', 'baz', 'bingo']

Last Updated: