Array.prototype.at is on its way
Written by Stefan Judis
- Published at
- Updated at
- Reading time
- 1min
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:
If you enjoyed this article...
Join 5.5k readers and learn something new every week with Web Weekly.
Reply to this post and share your thoughts via good old email.