TypeScript · Lesson 59 of 120
Generics Quiz
Test yourself.
Let's review generics. Pause after each question, and answer before I do.

- Generics quiz
- Pause and think
- Then check
Question 1
What does a type parameter like T do? It's a placeholder, filled in by each use.
Quick check
A type parameter T is:
Question 2
How do you require T to have a price? T extends an object with a price.
Quick check
Require a price with:
Question 3
What's the problem with any instead of generics? The type is lost.
Quick check
Using any instead of T:
Question 4
How do you give T a default? With an equals sign in the angle brackets.
Quick check
A default type parameter:
Summary
Well done. Next, a new section on type operators, starting with keyof.
Key takeaways- <T>
- extends
- = default
Next up: keyof — the keys as a type