Map and set getters to give a way to get an item at an order

Thanks for the engine-level analysis — this is really valuable.

A few thoughts:

  1. O(n) is fine : Array.prototype.at is O(1) because arrays are contiguous. For Maps/Sets, O(n) is acceptable as long as it's documented. Developers already pay O(n) when they do [...map.keys()][n] : but they also pay O(n) memory. .at(n) would be O(n) time but O(1) memory, which is still a win.
  2. JSC could optimize later : Even if it's O(n) today, nothing prevents JSC from changing to a flat array in the future. The API doesn't mandate performance, just behavior.
  3. Polyfill concern : You're right, but that's true for many proposals. Developers can feature-detect and use native when available, fall back to their own array otherwise. The existence of a polyfill doesn't block the proposal.

Really appreciate you digging into the engine details. This is exactly the kind of discussion I was hoping for.