Newb Array question

Hello,
I get that arrays are 0 based but why is arr.length = 5 and arr[5] = undefined?

const arr = [10, 9, 8 , 7, 6];

console.log(arr.length)
console.log(arr[5])

Because they use 0 based indexing.

An array with 5 elements has a length of 5 and the following are valid references

arr[0] - first element
arr[1] - second element
arr[2] - third element
arr[3] - 4th element
arr[4] - 5th element

If you attempt to reference a 6th element (like below), it does not exist, so it is undefined

arr[5] 

thank you for laying it out like that. Seeing that example made it make sense to me.