Sets are a compound data type introduced in ES6. A set is an array with duplicates removed and that prohibits adding duplicates. Try the following code:
const myArray = ['oh no', 'goodbye', null, true, 1, 'hello',{ 0 : 1 }]
myArray.push('goodbye')
console.log(myArray)
const mySet = new Set(myArray)
console.log(mySet)
mySet.add('goodbye')
console.log(mySet)
myArray will have a length of 8, while mySet will have a length of 7—even after trying to add 'goodbye'. JavaScript's .add() method of a set will first test to be sure a unique value is being added. Note the new keyword and the capitalization of the data type; this is not unique to creating sets, but it is important. In ES5 and before, it was common practice to declare new variables this way, but that practice is now considered legacy except for in a few instances.
There's a common introductory-level JavaScript question in interviews that asks you to deduplicate...