Type guard that checks if a value is null.
null
Type Narrowing Behavior:
true
The value to check
true if u is null, false otherwise. When true, TypeScript narrows the type to null.
u
false
const values: readonly (number | null)[] = [null, 5] as const;const nullValues = values.filter(isNull);assert.deepStrictEqual(nullValues, [null]); Copy
const values: readonly (number | null)[] = [null, 5] as const;const nullValues = values.filter(isNull);assert.deepStrictEqual(nullValues, [null]);
Type guard that checks if a value is
null
.Type Narrowing Behavior:
null
whentrue