TypeScript · Junior · Question 14 of 75

What is a tuple in TypeScript?

Explanation

type Point = [number, number] - exactly two numbers. Tuples are handy for returning several values, as in useState: [value, setter]. Elements can be named ([x: number, y: number]) and made optional ([string, number?]).

Further reading

Problem with a question

TypeScript · Junior · question 14

Test yourself

Take the TypeScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz