New: Master Frontend System Design! Read our brand new Meta-Guide and solve the Autocomplete practice challenge.Read Master Guide
FrontendPrep
TypeScript Quiz

Type Narrowing & Guards

Learn how to narrow types in TypeScript using typeof, instanceof, discriminated unions, type predicates, and exhaustiveness checks.

Question 1 of 100%

How does the `in` operator narrow a type in a conditional block?

javascript
if ('swim' in animal) {
  // What is the type of animal here?
}