Thanks for the engine-level analysis — this is really valuable.
A few thoughts:
- O(n) is fine :
Array.prototype.atis 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. - 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.
- 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.