What is a union type in TypeScript?

TypeScript Associate Medium

TypeScript Associate — Medium

What is a union type in TypeScript?

Key points

  • Union types use the '|' operator to specify multiple types
  • Provides flexibility for variables to hold different types
  • Helps in scenarios where a variable can have varied data types

Ready to go further?

Related questions