Intermediate
TypeScript
Q57 / 100
What is the result of widening for "let x = 'hello';" versus "const y = 'hello';"?
Correct! Well done.
Incorrect.
The correct answer is B) x is inferred as "string" (widened), y is inferred as the literal type "hello"
B
Correct Answer
x is inferred as "string" (widened), y is inferred as the literal type "hello"
Explanation
Mutable bindings (let/var) widen literal types to their general primitive type, while const preserves the literal type since it cannot change.
Progress
57/100