TypeScript Enums and Tuples Quiz
A 40-question TypeScript quiz covering numeric enums, string enums, const enums, reverse mapping, tuple types, readonly tuples, labeled tuples, and practical usage patterns.
Question 1
What keyword creates an enum in TypeScript?
Question 2
What values does Status.Active and Status.Inactive have?
enum Status { Active, Inactive }Question 3
Which type of enum supports reverse mapping?
Question 4
Which statement about string enums is true?
Question 5
What is Direction.Left?
enum Direction { Left = 'L', Right = 'R' }Question 6
What is a computed enum member?
Question 7
What value does E.B get?
enum E { A = 2, B }Question 8
Which enum type is fully erased during compilation?
Question 9
What is printed?
enum X { A, B }
console.log(X[1]);Question 10
Which statement describes enum merging?
Question 11
What values are valid members?
enum Flags { A = 1 << 0, B = 1 << 1 }Question 12
Why use enums instead of objects?
Question 13
What is a tuple in TypeScript?
Question 14
What type is Pair?
type Pair = [number, string];Question 15
Which operation is valid on a tuple?
Question 16
What prints?
const t: [number, number] = [1, 2];
console.log(t[1]);Question 17
What distinguishes a tuple from an array?
Question 18
Optional tuple elements use which notation?
Question 19
Which tuple definition allows extra elements?
type T = [string, ...number[]];Question 20
What do labeled tuples improve?
Question 21
What does this define?
type Coords = [x: number, y: number];Question 22
What does readonly do for tuples?
Question 23
What error occurs?
const p: readonly [number, number] = [3, 4];
p[0] = 10;Question 24
Which is a benefit of readonly tuples?
Question 25
What type is returned?
function use(): [string, number] { return ['x', 1]; }Question 26
Why use tuples for function returns?
Question 27
What prints?
const [a, b] = ['first', 2];
console.log(a);Question 28
Which tuple feature improves API clarity?
Question 29
What advantage do tuples have over arrays?
Question 30
What statement describes tuple assignment rules?
Question 31
Which describes a heterogeneous tuple?
Question 32
What are enum members treated as when used in types?
Question 33
Const enums are inlined at:
Question 34
Why should const enums be used carefully?
Question 35
Which describes tuple spreading?
Question 36
Which describes a union of tuples?
Question 37
What happens when accessing a tuple index out of range?
Question 38
Why might tuples be inappropriate for complex data?
Question 39
Which feature do enums provide?
Question 40
What advantage do tuples offer compared to multi-value objects?
