1Overloaded Funcitons:
2 Set of different functions which have same name.
3
4type Both = string | number;
5
6function add(a: number, b: number): number;
7function add(a: string, b: string): string;
8function add(a: Both, b: Both) {
9 if (typeof a === 'string' || typeof b === 'string') {
10 return a.toString() + b.toString();
11 }
12 return a + b;
13}
14
15const res = add('Joyous ', '21');
16console.log(res);
17