new Set()
from the given array to discard duplicated values....
) to convert it back to an array.const uniqueElements = arr => [...new Set(arr)];
uniqueElements([1, 2, 2, 3, 4, 4, 5]); // [1, 2, 3, 4, 5]
Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️