forEach()
method uses the value
variable twice for compatibility between Map and Set.
This use of the same value twice is to align with Map's callback structure. It may seem odd, but it makes replacing Map with Set easier in some cases, and vice versa.
let set = new Set(["orange", "apple", "banana"]);
set.forEach((value, valueAgain, set) => {
console.log(valueAgain); //"orange", "apple", "banana"
});
My question is how Set can be converted into Set and vice versa if there are no specific methods for this scenario?