Type guard that checks if a value is undefined.
undefined
Type Narrowing Behavior:
true
The value to check
true if u is undefined, false otherwise. When true, TypeScript narrows the type to undefined.
u
false
const values: (number | undefined)[] = [1, undefined, 2];const undefinedValues = values.filter(isUndefined);assert.deepStrictEqual(undefinedValues, [undefined]); Copy
const values: (number | undefined)[] = [1, undefined, 2];const undefinedValues = values.filter(isUndefined);assert.deepStrictEqual(undefinedValues, [undefined]);
Type guard that checks if a value is
undefined
.Type Narrowing Behavior:
undefined
whentrue