Jenis TypeScript Union

/*
TypeScript allows us to use more than one data type for a variable 
or a function parameter. This is called union type.
*/
let code: (string | number);
code = 123;   // OK
code = "ABC"; // OK
code = false; // Compiler Error

let empId: string | number;
empId = 111; // OK
empId = "E111"; // OK
empId = true; // Compiler Error
Tiny Coders