Intermediate
JavaScript
Q81 / 100
What is Array.prototype.at() and why was it added?
Correct! Well done.
Incorrect.
The correct answer is B) Returns the element at a given index, supporting negative indices for end-of-array access without .length arithmetic
B
Correct Answer
Returns the element at a given index, supporting negative indices for end-of-array access without .length arithmetic
Explanation
arr.at(-1) returns the last element. arr[arr.length-1] is equivalent but verbose. Also works on strings and TypedArrays.
Progress
81/100