Closed Rudxain closed 2 years ago
Yeah, this would be out of scope of this proposal and belongs to a follow-up proposal. You would have to find code that demonstrates that using arr[Number(bigInteger)]
is a common use case. 😃
(I would note that arrays are defined to have a limited space: their indices are not allowed to be 2 ** 32
or greater, and BigInts of course can exceed that limit. Of course, Numbers can exceed that too, so maybe this isn’t important.)
The only use case I can think of is in my math library. I have a module that does memoization and supports Number
s and BigInt
s.
And I agree, this should be in a follow-up proposal
I know this may be out of the scope of this proposal, but the fact that
['a', 'b', 'c'][x]
works regardless of whetherx
is aBigInt
or aNumber
whileat
throws an error just seems wrong. I don't know if there's any reason or justification about why this happens, but I hope polymorphism forat
becomes a thing. Please let me know if I'm missing something