Ramda’s R.isEmpty() answers a logic question: is this value the empty leftover of its own type? You pass one value. You get back true or false. Native JavaScript would write arr.length === 0 for lists and str === '' for strings. isEmpty names that idea once for lists, strings, objects, and typed arrays. Drop it into R.filter, R.reject, and R.ifElse.
The official sample is the whole idea. [], '', and {} are empty. [1, 2, 3] is not. null is not empty either — that is R.isNil. A plain object like { length: 0 } is not an empty array. Previous Logic helper is R.ifElse. Next is R.isNotEmpty.
Syntax
Call R.isEmpty. Start with this line.
Ramda
R.isEmpty(x)
Call
What it does
R.isEmpty(x)
Primary signature.
R.isEmpty(...)
Call the logic helper.
Prefer import { isEmpty } from "ramda" when you want a named import.
Library declarations
Ramda
R.isEmpty(x)
Parameters
Parameter
Description
x
Required. Any. The value to test. Lists, strings, objects, typed arrays, and other values are allowed.
Return Value
Return Value
Description
Boolean
true if x is its type's empty leftover. false otherwise, including for null and undefined.
Ramda Examples
📚 Getting Started
The official Ramda empty-list, empty-string, empty-object sample, then the same idea compared with isNil.
Example 1 — Official Empty List, String, and Object
A filled list is not empty. An empty list, string, or object is. null is not empty.
That matches the docs Uint8Array.from('') sample. R.complement(R.isEmpty) is the handmade form of isNotEmpty.
Compatibility
Browser Support
R.isEmpty() is ordinary JavaScript once Ramda is loaded. Logos use the shared browser-image-sprite.png sprite from this project.
✓ Ramda 0.1.0+ · Any JS runtime
Ramda.js R.isEmpty()
Load Ramda 0.1.0 or later via CDN or npm, then call R.isEmpty with one value. No extra browser API is required.
100%With Ramda 0.1.0+
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
R.isEmpty()Universal
Bottom line: Safe in any project that includes Ramda 0.1.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.isEmpty(x) returns true if x is its type's empty value, otherwise false. Added in v0.1.0. Type: a → Boolean. Arity 1, curried.
R.isEmpty([1, 2, 3]) is false. R.isEmpty([]) is true. R.isEmpty('') is true. R.isEmpty(null) is false. R.isEmpty({}) is true. R.isEmpty({ length: 0 }) is false. R.isEmpty(Uint8Array.from('')) is true.
No. Ramda treats null and undefined as not empty. R.isEmpty(null) is false. Use R.isNil for null or undefined.
isEmpty asks whether a value equals its type's empty leftover. isNil asks whether a value is null or undefined. An empty string is empty but not nil. null is nil but not empty.
No. That is a plain object with a length key, not an empty array. R.isEmpty({ length: 0 }) is false. R.isEmpty([]) is true.
No. R.isEmpty is a stable Ramda logic helper from v0.1.0. It is not deprecated, experimental, or non-standard.