Skip to content

isNil ​

The isNil function checks if the provided value is null or undefined.

Syntax ​

typescript
isNil(value: any): value is null | undefined;

Parameters ​

ParameterTypeDescription
valueanyValue to be checked

Returns ​

TypeDescription
booleanTrue if it is null or undefined

Examples ​

typescript
isNil(null); // => true
isNil(undefined); // => true
isNil(0); // => false

Notes ​

  • Useful for validating absence of value.

References ​

Released under the MIT License.