Remove Array Duplicates

PHOTO EMBED

Thu Jun 30 2022 02:13:50 GMT+0000 (UTC)

Saved by @Mahmoudsalamazz #javascript #array #set

const removeArrDup = (arr = []) => [... new Set(arr)]

removeArrDup([1,1,2,2,2,3])
// Expect output to be  [1,2,3]
content_copyCOPY

A Set is a collection of unique values. To remove duplicates from an array: First, convert an array of duplicates to a Set. The new Set will implicitly remove duplicate elements. Then, convert the set back to an array.