Array.prototype.at is on its way
- Published at
- Updated at
- Reading time
- 1min
This post is a note that includes my thoughts about something I found online. Check it out yourself!
I just saw that Array
will ship in Chrome 89 and Firefox 85. How do I know? I'm following the MDN browser combat data repo on GitHub. ๐
const numbers = [1, 2, 3];
// old way to access array elements from the end
numbers[numbers.length - 1]; // 3
// new way to access array elements from the end
numbers.at(-1); // 3
That's a welcome addition to the language! ๐
Update: one year after publishing this post and this new valuable Array method is almost ready for prime time! Here's the up-to-date MDN browser compat data:
MDN Compat Data (source)
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
92 | 92 | 92 | 90 | 90 | 15.4 | 15.4 | 16.0 | 92 |
Additional resources:
Was this post helpful?
Yes? Cool! You might want to check out Web Weekly for more WebDev shenanigans. The last edition went out 9 days ago.
Yes? Cool! You might want to check out Web Weekly for more WebDev shenanigans. The last edition went out 9 days ago.