Ramda.js R.isNotNil() Method

Beginner
5 min read
Updated: Nov 2026
5 examples
Type

Definition

Ramda’s R.isNotNil() answers a yes/no question: is this value present? Present means neither null nor undefined — both missing leftovers must fail. You pass one value. You get back a Boolean. It is the named form of R.complement(R.isNil), the same pattern as R.isNotEmpty for R.isEmpty. Native JavaScript would write x != null. isNotNil names that idea as a curried helper you can drop into R.filter. It is not a truthy check: 0, '', false, NaN, and [] are present. Need a missing Boolean? That is Type cousin R.isNil — exact flip. Need a constructor Boolean? That is Type cousin R.is. Need a string tag? That is Type cousin R.type. Need filled vs empty? That is R.isNotEmpty: R.isNotEmpty(null) is true while R.isNotNil(null) is false. Need a fallback? R.defaultTo also treats NaN as missing; R.isNotNil(NaN) is true. Need a property that matches a constructor? That is Type cousin R.propIs.

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

Syntax

Call R.isNotNil. Start with this line.

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

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

Library declarations
Ramda
R.isNotNil(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 not null and not undefined, otherwise false.

Ramda Examples

📚 Getting Started

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

Example 1 — Official Samples

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

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

How It Works

That is the docs sample from ramdajs.com. Missing values are false. A zero and an empty list are present leftovers, so they are true. Example 2 shows the exact flip against isNil.

Example 2 — vs R.isNil

Same four official leftovers. Every Boolean is the exact flip of isNil.

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

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

How It Works

Two columns, same values. isNotNil is present. isNil is missing. R.isNotNil === R.complement(R.isNil). Example 3 then splits present from filled.

📈 Practical Patterns

Present vs filled, falsy leftovers that still pass, then a curried filter plus complement.

Example 3 — vs R.isNotEmpty

null is notNil false / notEmpty true. [] is notNil true / notEmpty false.

Ramda
const rows = [
  ['null', R.isNotNil(null), R.isNotEmpty(null)],
  ['[]', R.isNotNil([]), R.isNotEmpty([])]
];

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

How It Works

Missing leftover is not empty leftover, so isNotEmpty(null) is true. An empty list is present, so isNotNil is true, but it is type-empty, so isNotEmpty is false.

Example 4 — Falsy but Present

0, false, '', and NaN all fail Boolean(x). All of them are present. Complement matches the named helper.

Ramda
R.isNotNil(0);
//=> true

R.isNotNil(false);
//=> true

R.isNotNil('');
//=> true

R.isNotNil(NaN);
//=> true

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

How It Works

Falsy is a JavaScript truthiness leftover. Present is only “not missing.” If you wrote list.filter(Boolean), zeros and empty strings would vanish. R.filter(R.isNotNil, list) keeps them. R.defaultTo would still replace NaN.

Example 5 — Curried leftover with R.filter

Arity 1: pass isNotNil into filter. 0 and '' stay. null and undefined drop.

Ramda
R.filter(R.isNotNil, [1, null, 0, undefined, '']);
//=> [1, 0, '']
Try It Yourself

How It Works

R.isNotNil is already a predicate. filter keeps items that pass. Same leftover as R.reject(R.isNil, list) for this list.

Browser Support

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

✓ Ramda 0.29.0+ · Any JS runtime

Ramda.js R.isNotNil()

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

100% With Ramda 0.29.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.isNotNil() Universal

Bottom line: Safe in any project that includes Ramda 0.29.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], which includes the helper.

Frequently Asked Questions

R.isNotNil(x) returns true when x is neither null nor undefined, otherwise false. Present means both missing leftovers fail. Type: * → Boolean. Parameter x is the value to test. Returns Boolean. Arity 1, curried, so you can pass R.isNotNil into R.filter. Added in v0.29.0.
R.isNotNil(null) is false. R.isNotNil(undefined) is false. R.isNotNil(0) is true. R.isNotNil([]) is true.
They are complements. Every leftover that isNil calls true, isNotNil calls false, and the other way around. Same four official values, exact Boolean flip.
isNotEmpty asks whether a value is not its type's empty leftover. isNotNil asks whether a value is present (not null and not undefined). R.isNotEmpty(null) is true; R.isNotNil(null) is false. [] is notNil true and notEmpty false.
No. Boolean(0), Boolean(''), Boolean(false), and Boolean(NaN) are false. R.isNotNil is true for all of them. Only null and undefined are missing.
No. R.isNotNil is a stable Ramda Type helper from v0.29.0. It is not deprecated, experimental, or non-standard.

Continue to R.propIs()

Learn how to test whether a named property on an object matches a constructor with Ramda R.propIs().

R.propIs() 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