Loading...
for (const [i, tag] of tags.entries()) {
console.log(i, tag);
}for (const [i, tag] of [...tags].entries()) {
console.log(i, tag);
}Set entries are [value, value], so i was the tag itself; converting to an array gives real indexes.
entries() to return indexes like Array.prototype.entries().values(), not entries().entries() at all?For a shared interface with Map, so code that iterates [key, value] pairs works on both.
set.entries() an array?No. It returns an iterator; spread it or use Array.from() to get an array of pairs.