JavaScript · Junior · Question 36 of 75
What does const arr = ['a', 'b']; console.log(arr[20]); print?
- ✓Correct answer:
undefined - 2
RangeError - 3
null
Explanation
Accessing a nonexistent index, like a missing object property, returns undefined without an error. For the last element, arr.at(-1) is handy.