JavaScript · Junior · Question 48 of 75

How do you quickly remove duplicates from an array of primitives?

Explanation

Set stores only unique values (SameValueZero comparison). Spread turns it back into an array. Arrays of objects need a key: for example, a Map by id.

Further reading

Problem with a question

JavaScript · Junior · question 48

Test yourself

Take the JavaScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz