This function removes duplicate values from an array.
JavaScript:
let removeDuplicates = arr => [...new Set(arr)];
// Example
console.log(removeDuplicates([1, 2, 2, 3, 3, 3])); // [1, 2, 3]
console.log(removeDuplicates(['a', 'a', 'b', 'b', 'c', 'c'])); // ['a', 'b', 'c']
TypeScript:
let removeDuplicates = (arr: T[]): T[] => [...new Set(arr)];
// Example
console.log(removeDuplicates([1, 2, 2, 3, 3, 3])); // [1, 2, 3]
console.log(removeDuplicates(['a', 'a', 'b', 'b', 'c', 'c'])); // ['a', 'b', 'c']