Array.prototype.at is on its way (#note)

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…

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:


Reply to Stefan
Print Share Comment Cite Upload Translate
CITATION GOES HERE CITATION GOES HERE
Select a language: