How do you remove duplicates from an array in JavaScript?
a) Using
Set()b) Using
Array.filter()c) Using
Array.reduce()d) Using
Array.map()Answer:
a) Using
Set()Explanation:
One of the easiest ways to remove duplicates from an array in JavaScript is by using Set(). A Set object stores unique values, and you can convert the array to a Set and back to an array to remove duplicates.