01 / 05
Writing "it could be either"
Every type so far has been "just this one". string means only text, number means only numbers.
But in real life there are places where either one is possible. A queue number that some people hold as 12 and others as "A12", say. That is where a union type comes in — types joined together with |.
let ticket: string | number = 12;console.log(ticket);ticket = "A12";console.log(ticket);Result
12 A12