Which of the following constrains a generic type to objects with a length property?
function logLength<T extends { length: number }>(arg: T): void {
console.log(arg.length);
}
The generic type T must be a number.
The generic type T must be a string.
The generic type T must have a length property.
The function is invalid because T cannot have constraints.
This question is part of this quiz :
Generics in TypeScript QuizTypeScript | Generics in TypeScript | Question6