What does the ‘instanceof’ type guard check in TypeScript?

TypeScript Associate Medium

TypeScript Associate — Medium

What does the ‘instanceof’ type guard check in TypeScript?

Key points

  • 'instanceof' specifically checks for class instances
  • It narrows down the type to the specific class
  • Useful for ensuring type correctness in TypeScript
  • Different from checking for properties or interfaces

Ready to go further?

Related questions