TypeScript Master CourseBeginner Friendly
Union and Intersection Types
Learn Union and Intersection Types with simple explanations, practical examples, interview questions, MCQs and hands-on practice.
📘 Chapter 9 / 25⏱️ 8–10 Min Read🎯 Beginner Friendly
Course Progress36%
Course Progress
36%9 / 25 chapters
📖
Theory
Understand the concept step by step
A union type allows a value to be one of several types.
An intersection type combines multiple types into one.
💻
Example
See how the concept works in real code
TypeScript
let id: string | number;
id = 101;
console.log(id);
id = "USER101";
console.log(id);📤
Output
Understand what the code produces
101 USER101
📝
Practice
Test your understanding
Practice the Union and Intersection Types concept by writing your own TypeScript example.
❓
MCQs
Check your knowledge
What is the main topic covered in Union and Intersection Types?
A.Union and Intersection Types
B.JavaScript Runtime
C.Database Management
D.Operating System
💼
Interview Questions
Prepare for TypeScript interviews
1
Interview Question
What is a union type?
2
Interview Question
What is an intersection type?
3
Interview Question
When would you use a union type?