TypeScript Intermediate Quiz
Explore generics, enums, and more advanced type manipulations.
Start the quizSample questions from this quiz
A preview of the style and depth. Try each one, then reveal the answer — or skip straight to the timed quiz.
1. What is a generic in TypeScript?
function identity<T>(arg: T): T { return arg; }- A reusable component that can work with a variety of types.
- A base class for other classes.
- A special type of interface.
- A way to generate code.
Show answer
Answer: A reusable component that can work with a variety of types.. Generics allow you to create reusable components (functions, classes, interfaces) that can work over a variety of types rather than a single one.
2. How do you define a numeric enum?
enum Direction { Up, Down, Left, Right }- enum Direction { Up, Down, Left, Right }
- type Direction = 'Up' | 'Down';
- const Direction = ['Up', 'Down'];
- interface Direction { Up, Down }
Show answer
Answer: enum Direction { Up, Down, Left, Right }. By default, enums are number-based, with the first member being 0 and auto-incrementing from there.
3. What is the value of `Direction.Left` in this enum?
enum Direction { Up = 1, Down, Left, Right }- 1
- 3
- 0
- 2
Show answer
Answer: 3. When one member is initialized (Up = 1), subsequent members auto-increment. So, Down is 2, and Left is 3.
Frequently asked questions
How many questions are in this TypeScript quiz?+
30 questions, with a 60-minute time limit. Every question includes a written explanation of the correct answer.
Is this TypeScript quiz free?+
Yes. Every quiz on CodexQuizz is free and needs no account. You only enter a name if you choose to post your score to the leaderboard.
What level is the intermediate quiz aimed at?+
Explore generics, enums, and more advanced type manipulations.
Can I use this to prepare for a TypeScript interview?+
Yes. The questions cover the topics that come up in TypeScript technical screens, and the explanations are written so that a wrong answer still teaches you the underlying concept.
Ready to test your TypeScript?
30 questions, 60 minutes. Free, no sign-up.
Start now