JavaScript function to create a duplicate-free copy of an array
Sets are basically like magic for pulling unique values from an array; since, by their very definition, any Set will only hold one copy of any specific value, no matter how many times you try to add it.

That, combined with the ability of Sets to be easily turned back into arrays using the spread operator, makes the overall task rather straight-forward:

function noDuplicates(arr){
  return [...new Set(arr)]
}


It actually makes the task so quick and easy that it begs the question of whether a function is even needed; since anytime you need to pull only the unique values of an array you can simply use:

var unique = [...new Set(arr)] 


Both the function-based and non-function-based approaches are fully viable options though, so choose whichever you prefer.  Hope this was helpful!