What does `Array.prototype.at(-1)` return?

JavaScript Developer Easy

JavaScript Developer — Easy

What does `Array.prototype.at(-1)` return?

Key points

  • The method `at(-1)` specifically targets the last element.
  • It is different from accessing the first element or returning undefined.
  • Negative indexes in JavaScript arrays count from the end.

Ready to go further?

Related questions