Which of the following is a correct use of the ReadonlyArray<T> built-in generic type?
function printNumbers(numbers: ReadonlyArray<number>): void {
numbers.forEach((num) => console.log(num));
// numbers.push(10); // Error
}
It ensures the array numbers cannot be modified.
It allows adding new elements to numbers.
It is identical to a regular array.
It throws an error at runtime if numbers is modified.
This question is part of this quiz :
Generics in TypeScript Quiz