tc39 / proposal-bigint-math

Draft specification for supporting BigInts in JavaScript’s Math methods.

Home Page:https://tc39.es/proposal-bigint-math/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The `at` method of indexables should support `BigInt`s

Rudxain opened this issue · comments

I know this may be out of the scope of this proposal, but the fact that ['a', 'b', 'c'][x] works regardless of whether x is a BigInt or a Number while at 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 for at becomes a thing. Please let me know if I'm missing something

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 Numbers and BigInts.

And I agree, this should be in a follow-up proposal