Set.prototype.forEach which accepts a callback function in ES6 The function has 3 parameters to be consistent with Map.prototype.forEach. MDN says both the first 2 parameters for the callback are values because there is no keys in Set object. Why the item in Set is considered as value instead of key? No duplicated key in Set object would make more sense because there is also no duplicated key in Map.
Another aspect that value in Set looks like key in Map is that it makes Set.prototype.has(value) and Map.prototype.has(key) more consistent. Duplicated keys are NOT allowed in Array (key is index) and Map, but this cannot be extended to Set which doesn't allow duplicated values. Make it as duplicated keys are not allowed in all containers might be a more succinct rule.
Mapobject has a key and a value which are separate entities. ASetobject just has a value which you use to add the value to theSetand use to test if the value is in theSet. Essentially, aSetis indexed by the value so it's kind of like aSetis aMapwhere the key and value are the same.Setas key instead of value might be more appropriate. So my question ist still why the stand calls item inSetas value, not as key. :)