TypeScript · Middle · Question 38 of 75
What does the ReadonlyArray<T> utility (or readonly T[]) do?
- ✓Correct answer: Removes mutating methods (
push,sort) from the type - 2Freezes the array at runtime via
Object.freeze - 3Makes all array elements deeply immutable
Explanation
A readonly T[] parameter guarantees the caller that the function won't modify their array. It accepts regular arrays too. The type doesn't prevent changing nested objects - it's shallow protection.