undefined
A variable declared but not initialized is undefined
. Undefined is not quite the same as the type null
. In both cases, an assignment can set undefined
or null
to a variable explicitly. The following code does not compile because the variable is consumed before initialization and TypeScript when configured to be strict, does not allow for interaction with an unassigned variable.
Get hands-on with 1400+ tech skills courses.