For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /reference/predicate/isNull.md.

isNull es-toolkit

Checks if a value is null.

const result = isNull(value);

Usage

isNull(value)

Use isNull when you want to check if a value is exactly null. It uses strict equality (===) to recognize only null and not undefined.

import { isNull } from 'es-toolkit/predicate';

// null value
console.log(isNull(null)); // true

// Non-null values
console.log(isNull(undefined)); // false
console.log(isNull(0)); // false
console.log(isNull('')); // false
console.log(isNull(false)); // false
console.log(isNull([])); // false
console.log(isNull({})); // false

It can also be used as a type guard in TypeScript.

function processValue(value: string | null | undefined) {
  if (isNull(value)) {
    // value is now narrowed to null
    console.log('Value is null');
  } else {
    // value is narrowed to string | undefined
    console.log('Value is not null:', value);
  }
}

isNull is different from isNil in that it treats undefined as false.

import { isNil, isNull } from 'es-toolkit/predicate';

console.log(isNull(undefined)); // false
console.log(isNil(undefined)); // true

Parameters

valueunknownrequired

The value to check if it's null.

Returns

Returns true if the value is null, false otherwise.

value is null
Source: es-toolkit

Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.