TypeScript
Union vs intersection
Union types allow one of several types, intersection types combine them.
Union
let id: string | number;function printId(id: string | number) {
if (typeof id === "string") return id.toUpperCase();
return id.toFixed(2);
}Intersection
interface Person { name: string }
interface Employee { id: number }
type Worker = Person & Employee;