Union Types

Last updated

What is Union Types?

Union types allow a variable to hold values of different types. This means you can specify that a variable can be, for example, either a string or a number. You define a union type using the pipe (|) symbol to separate the possible types. This provides flexibility in situations where a variable might accept multiple different data types.

Free resources to learn Union Types

More in stage 5: Combining Types

Union Types: common questions

Can I learn Union Types in Hindi?

This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain Union Types in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.

Is this Union Types tutorial for beginners?

It is lesson 32 of 93 in the free TypeScript roadmap, in stage 5, Combining Types. If you are new to TypeScript, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.

Still confused? Ask me