TypeScript · Junior · Question 53 of 75

What type does const direction = 'left'; get?

Explanation

A const can't be reassigned, so TypeScript keeps the literal. With let direction = 'left' it widens to string.

Further reading

Problem with a question

TypeScript · Junior · question 53

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