CyrefJS
CCyrefJS
فا
Back to documentation
Type/Since 1.38.0

isUndefined

Checks whether a value is exactly undefined.

isUndefined(value):value is undefined

Behavior

The function uses strict equality (===) to check whether the provided value is exactly undefined.

Undefined vs Null

Only undefined returns true. The value null is not considered undefined.

Type Guard

The return type is value is undefined, allowing TypeScript to narrow the value to undefined inside a conditional branch.

Parameters

valueunknownrequired

The value to check.

Returns

value is undefined

Returns true when the value is exactly undefined; otherwise, returns false.

Examples

01

Basic usage

Check whether different values are undefined.

TypeScript
import { isUndefined } from "@cyref/js";

isUndefined(undefined);
// true

isUndefined(null);
// false

isUndefined(0);
// false

isUndefined("");
// false

isUndefined(false);
// false
02

Type narrowing

isUndefined acts as a TypeScript type guard and narrows the value to undefined when it returns true.

TypeScript
const value: string | undefined = undefined;

if (isUndefined(value)) {
  // value is undefined
}
Built with@cyref/js·Official documentation