Checks if a value is Defined.
Only undefined is rejected: null and falsy values such as 0, "", and false are all defined. On success the value narrows to its declared type without undefined, so the guard doubles as a filtering predicate, as in values.filter(isDefined).
undefined
null
0
""
false
values.filter(isDefined)
The declared type of the value to check
The value to check
True if the value is not undefined; false otherwise
Checks if a value is Defined.
Only
undefinedis rejected:nulland falsy values such as0,"", andfalseare all defined. On success the value narrows to its declared type withoutundefined, so the guard doubles as a filtering predicate, as invalues.filter(isDefined).