An array and an object have been the two main types that JavaScript developers have used for quite some time. But, we now have two other collection types that help us do some things that we used to use these other types for. These are set and map. A set is an unordered collection of unique items. What this means is that if we try to put something in the set that is already there, we will notice that we only have a single item. We can easily simulate a set with an array like so:
const set = function(...items) { this._arr = [...items]; this.add = function(item) { if( this._arr.includes(item) ) return false; this._arr.push(item); return true; } this.has = function(item) { return this._arr.includes(item); } this.values = function() ...