) to access an element at a specific index of an array. For instance, the
arr returns the first element in the array
arr returns the fourth element, and so on.
And To get the last element in an array, you use the length property like this:
But you can’t use the negative integer with square bracket notation if you used the negative integer with square bracket notation(
), it returns
undefined. To overcome this issue, ES2022 introduced a new method
at() added to the prototype of Array, String, and TypeArray.
Array.prototype.at()method used to get the element of the specific index.
Here are some examples of
Share your valuable feedback, please post your comment at the bottom of this article. Thank you!