TypeScript lets us define array types as read-only so that we get a type error if we attempt to add, remove, or replace any elements of the array. We can use the readonly
keyword to make an array type read-only. Alternatively, we can use the ReadonlyArray<T>
type instead of Array<T>
or T[]
.