Array.prototype.atintermediateconst arr = [1, 2, 3]
arr.at(5) // β undefined
arr.at(-5) // β undefinedat() returns undefined when the index is out of bounds, making it safe for optional access.
.at(n) returns undefined when n is out of bounds (either too large or too negative). This makes it a safe alternative to bracket notation.
Challenge: Implement safeAt(arr, n) that returns arr.at(n), which is undefined if the index is out of bounds.
safeAt([1, 2, 3], 10) // β undefined
safeAt([1, 2, 3], -5) // β undefined
safeAt([1, 2, 3], 1) // β 2