1let age: number | undefined;
2age = 18;
3
4if (age) {
5 // This will run because age is not null or undefined
6}
7
8age = undefined;
9
10if (age) {
11 // This will not run because age is undefined
12}
13
14// If you want to do something when it is undefined
15if (age === undefined) {
16 // This will run because age is undefined
17}