Ramda.js R.isNil() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Type

Definition

Ramda’s R.isNil() answers a yes/no question: is this value missing? You pass one value. You get back a Boolean. Native JavaScript would write x == null (loose equality catches both null and undefined). isNil names that idea as a curried helper you can drop into R.reject and R.filter. It is not a falsy check: 0, '', false, NaN, and [] are not nil. Need a constructor Boolean? That is Type cousin R.is — isNil does not take a constructor. Need a string tag? That is Type cousin R.type: type(null) is "Null", type(undefined) is "Undefined", and isNil is true for both. Need empty vs filled? That is R.isEmpty or R.empty: [] and '' are empty, null is not empty. Need a fallback? Pair with R.defaultTo. Lodash _.isNil is the same idea. Named complement is R.isNotNil (v0.29.0). Need a property constructor check? That is Type cousin R.propIs.

The official sample is the whole idea. null and undefined are true. 0 and [] are false. Previous helper is R.is. Next is R.isNotNil.

Syntax

Call R.isNil. Start with this line.

Ramda
R.isNil(x)
CallWhat it does
R.isNil(x)Primary signature.
R.isNil(...)Call the type helper.

Prefer import { isNil } from "ramda" when you want a named import.

Library declarations
Ramda
R.isNil(x)

Parameters

ParameterDescription
xRequired. Any. The value to test. Primitives, objects, arrays, null, and undefined are allowed.

Return Value

Return ValueDescription
Booleantrue if x is undefined or null, otherwise false.

Ramda Examples

📚 Getting Started

The official Ramda samples in one snippet, then the same values next to R.isEmpty.

Example 1 — Official Samples

Every docs line in one list. One value in, Boolean back. Only null and undefined are true.

Ramda
R.isNil(null);      //=> true
R.isNil(undefined); //=> true
R.isNil(0);         //=> false
R.isNil([]);        //=> false
Try It Yourself

How It Works

That is the docs sample from ramdajs.com. Missing values are true. A zero and an empty list are present leftovers, so they are false. Example 2 splits the same idea from empty leftovers.

Example 2 — vs R.isEmpty

null is nil, not empty. '' and [] are empty, not nil. 0 is neither.

Ramda
const rows = [
  ['null', R.isNil(null), R.isEmpty(null)],
  ["''", R.isNil(''), R.isEmpty('')],
  ['[]', R.isNil([]), R.isEmpty([])],
  ['0', R.isNil(0), R.isEmpty(0)]
];

rows;
//=> [
//     ["null", true, false],
//     ["''", false, true],
//     ["[]", false, true],
//     ["0", false, false]
//   ]
Try It Yourself

How It Works

Two columns, same values. isNil is missing. isEmpty is a type’s blank leftover. R.isEmpty(null) is false on purpose. Example 3 then lists falsy leftovers that still fail isNil.

📈 Practical Patterns

Falsy leftovers that are not nil, Null vs Undefined both isNil, then a curried reject plus defaultTo.

Example 3 — Falsy Leftovers That Are Not Nil

0, false, '', and NaN all fail if (x). None of them is nil.

Ramda
R.isNil(0);
//=> false

R.isNil(false);
//=> false

R.isNil('');
//=> false

R.isNil(NaN);
//=> false
Try It Yourself

How It Works

Falsy is a JavaScript truthiness leftover. Nil is only missing. If you wrote list.filter(Boolean), zeros and empty strings would vanish. R.reject(R.isNil, list) keeps them.

Example 4 — vs R.type: Null and Undefined

R.type splits the tags. isNil is true for both. typeof null is still "object".

Ramda
R.type(null);
//=> "Null"

R.isNil(null);
//=> true

R.type(undefined);
//=> "Undefined"

R.isNil(undefined);
//=> true

typeof null;
//=> "object"
Try It Yourself

How It Works

Use type when you need the native kind name. Use isNil when both missing leftovers should share one Boolean. Do not trust typeof null for a missing check.

Example 5 — Curried leftover with R.reject and R.defaultTo

Arity 1: pass isNil into reject. 0 and '' stay. Pair with defaultTo when a missing leftover should become a fallback.

Ramda
R.reject(R.isNil, [1, null, 0, undefined, '']);
//=> [1, 0, '']

R.filter(R.complement(R.isNil), [1, null, 0]);
//=> [1, 0]

R.defaultTo(0, null);
//=> 0
Try It Yourself

How It Works

R.isNil is already a predicate. reject drops items that pass. R.complement(R.isNil) is the handmade form of R.isNotNil. R.defaultTo also treats NaN as missing, which isNil does not.

Browser Support

R.isNil() is ordinary JavaScript once Ramda is loaded. Logos use the shared browser-image-sprite.png sprite from this project.

✓ Ramda 0.9.0+ · Any JS runtime

Ramda.js R.isNil()

Load Ramda 0.9.0 or later via CDN or npm, then call R.isNil with one value. No extra browser API is required.

100% With Ramda 0.9.0+
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
R.isNil() Universal

Bottom line: Safe in any project that includes Ramda 0.9.0 or later. Use a CDN build such as ramda.min.js in the browser or install ramda from npm for Node. These labs use [email protected].

Frequently Asked Questions

R.isNil(x) returns true when x is null or undefined, otherwise false. Type: * → Boolean. Parameter x is the value to test. Returns Boolean. Arity 1, curried, so you can pass R.isNil into R.reject or R.filter. Added in v0.9.0.
R.isNil(null) is true. R.isNil(undefined) is true. R.isNil(0) is false. R.isNil([]) is false.
isEmpty asks whether a value equals its type's empty leftover. isNil asks whether a value is null or undefined. [] and '' are empty but not nil. null is nil but not empty: R.isEmpty(null) is false, R.isNil(null) is true.
No. 0, false, '', NaN, and [] are falsy in JavaScript but R.isNil is false for all of them. Only null and undefined are nil.
R.type(null) is "Null" and R.type(undefined) is "Undefined". R.isNil is true for both. It does not return a string tag; it returns one Boolean that covers missing values.
No. R.isNil is a stable Ramda Type helper from v0.9.0. It is not deprecated, experimental, or non-standard. R.isNotNil (v0.29.0) is the named complement.

Continue to R.isNotNil()

Learn the named complement of isNil — a present-side Boolean that keeps zeros and empty strings.

R.isNotNil() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

6 people found this page helpful