/* Use || operator to assign a default value whence the first variable
evaluates to a 'falsy' value
- Example with strings (you can replace string with any type T) */
let x: string | null = null;
let y: string = x || "My default value"
The value undefined means value is not assigned
& you don’t know its value.
It is an unintentional absence of value.
It means that a variable has been declared but has not yet
been assigned a value.
The value null indicates that you know that the field does not
have a value. It is an intentional absence of value.
/* Use || operator to assign a default value whence the first variable
evaluates to a 'falsy' value
- Example with strings (you can replace string with any type T) */
let x: string | null = null;
let y: string = x || "My default value"
The value undefined means value is not assigned
& you don’t know its value.
It is an unintentional absence of value.
It means that a variable has been declared but has not yet
been assigned a value.
The value null indicates that you know that the field does not
have a value. It is an intentional absence of value.