Proposal: GitHub - tc39/proposal-relative-indexing-method: A TC39 proposal to add an .at() method to all the basic indexable classes (Array, String, TypedArray)
I know that the
.at method is already in Stage 4 and it is not the right time to talk about its specification, but I decided to create this topic because its specification is very very harmful.
Take a look at the following code:
const arr = [1, 2, 3]; console.log(arr.at("foo")); // => 1 console.log(arr.at(NaN)); // => 1 console.log(arr.at(1.5)); // => 2
IMO, they should all return
The reason this happens is that the argument goes through
ToIntegerOrInfinity. Instead, it should go through
ToNumber and then validated with
I know that it has already been shipped to the browsers, but could you please consider fixing it once again?