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.prototype.at
will ship in Chrome 89 and Firefox 85. How do I know? I'm watching 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! 🎉
Additional resources: