Introduction
Union types let you say a value can be one of several types. This helps your program accept different kinds of inputs safely.
When a function can accept either a string or a number as input.
When a variable might hold a value that can be a boolean or a string.
When you want to allow multiple types for a parameter but still keep type safety.
When reading data that might come in different formats, like a string or an array.