TypeScript Union
example code: In this example, data is defined as a Union type that can be either a string or a number. You can assign values of either type to value, and the type of value will adjust accordingly. Note: Once you assign a value of a certain type to a Union , you can only …