Intermediate
TypeScript
Q50 / 100
What does the following do? "function isString(val: unknown): val is string { return typeof val === 'string'; }"
Correct! Well done.
Incorrect.
The correct answer is A) Defines a type guard that narrows "val" to string when it returns true
A
Correct Answer
Defines a type guard that narrows "val" to string when it returns true
Explanation
The "val is string" return type is a user-defined type guard, narrowing the type of val within branches where the function returns true.
Progress
50/100