Set
from the mapped values to keep only unique occurrences.Array.prototype.length
and Set.prototype.size
to compare the length of the unique values to the original array.const allUnique = arr => arr.length === new Set(arr).size;
allUnique([1, 2, 3, 4]); // true allUnique([1, 1, 2, 3]); // false
Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️