Set.prototype.entries: indices as keys?

Axel Rauschmayer axel at
Sun Jan 18 04:28:01 PST 2015

Currently the keys of the entries returned by `Set.prototype.entries()` are the same as the values:

let set = new Set(['a', 'b']);

let pairs = [...set.entries()];
console.log(JSON.stringify(pairs)); // [["a","a"],["b","b”]]

Given that sets are ordered, I’d use the “position” of an entry as the key: [[0,"a"],[1,"b”]]

Rationale: First, having an indices as keys makes the entries more useful. Second, destructuring already treats entries as if they had indices:

let [x,y] = set; // x='a'; y='b’;

Dr. Axel Rauschmayer
axel at

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list