How to determine if a variable is undefined
Using the typeof Operator
The typeof operator can be used to check if a variable or expression is undefined.
You can directly compare a variable to undefined to check if it's undefined.
Using the === Operator
The === operator performs strict equality comparison, which can be used to check if a value is exactly undefined.
If a function parameter is not provided, it's set to undefined. You can check this way:
You can also check if a property of an object is undefined.