TypeScript card reviewmedium

What are Union Types in TypeScript?

Union Types allow a variable to hold multiple possible types. They are defined using the pipe (|) operator. Union Types improve flexibility while maintaining type safety and are commonly used when a value can belong to more than one type.

JB

Jeevan Bhargav

Audited by Creator

This answer is calibrated for technical interviews. Verify benchmarks in local sandboxes before deploying.