or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.md
tile.json

tessl/npm-lodash-isempty

Checks if values are empty including arrays, objects, strings, arguments objects, and jQuery-like collections.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/lodash.isempty@3.0.x

To install, run

npx @tessl/cli install tessl/npm-lodash-isempty@3.0.0

index.mddocs/

lodash.isempty

The modern build of lodash's _.isEmpty utility function exported as a standalone Node.js module. Provides comprehensive empty-checking functionality for various JavaScript data types including arrays, objects, strings, arguments objects, and jQuery-like collections.

Package Information

  • Package Name: lodash.isempty
  • Package Type: npm
  • Language: JavaScript
  • Installation: npm install lodash.isempty

Core Imports

var isEmpty = require('lodash.isempty');

Basic Usage

var isEmpty = require('lodash.isempty');

// Check primitive values
isEmpty(null);        // => true
isEmpty(undefined);   // => true  
isEmpty(true);        // => true
isEmpty(1);           // => true

// Check collections
isEmpty([]);          // => true
isEmpty([1, 2, 3]);   // => false
isEmpty({});          // => true
isEmpty({ 'a': 1 });  // => false
isEmpty('');          // => true
isEmpty('hello');     // => false

Capabilities

Empty Value Detection

Checks if a value is considered empty across various JavaScript data types.

/**
 * Checks if `value` is empty. A value is considered empty unless it's an
 * `arguments` object, array, string, or jQuery-like collection with a length
 * greater than `0` or an object with own enumerable properties.
 *
 * @static
 * @memberOf _
 * @category Lang
 * @param {Array|Object|string} value The value to inspect.
 * @returns {boolean} Returns `true` if `value` is empty, else `false`.
 */
function isEmpty(value);

Behavior:

  • Returns true for null and undefined values
  • Returns true for primitive values (numbers, booleans, symbols)
  • For array-like values (arrays, strings, arguments objects, jQuery-like collections): returns true if length is 0
  • For objects (including functions, Date objects, etc.): returns true if no own enumerable properties exist
  • For functions with a splice method (jQuery-like collections): treated as array-like

Usage Examples:

var isEmpty = require('lodash.isempty');

// Null and undefined
isEmpty(null);           // => true
isEmpty(undefined);      // => true

// Primitives  
isEmpty(true);           // => true
isEmpty(false);          // => true
isEmpty(0);              // => true
isEmpty(42);             // => true
isEmpty(NaN);            // => true

// Strings
isEmpty('');             // => true
isEmpty('hello');        // => false
isEmpty('   ');          // => false (whitespace counts as content)

// Arrays
isEmpty([]);             // => true
isEmpty([1, 2, 3]);      // => false
isEmpty(new Array(3));   // => false (sparse arrays have length)

// Objects
isEmpty({});             // => true
isEmpty({ a: 1 });       // => false
isEmpty({ length: 0 });  // => false (has enumerable property)

// Arguments objects
function testArgs() {
  return isEmpty(arguments);
}
testArgs();              // => true
testArgs(1, 2);          // => false

// Array-like objects (jQuery-style)
isEmpty({ 0: 'a', length: 1, splice: Array.prototype.splice }); // => false
isEmpty({ length: 0, splice: Array.prototype.splice });         // => true

// Functions (treated as objects)
isEmpty(function() {});      // => true
isEmpty(function() { this.a = 1; }); // => true (function object has no enumerable properties)

// Date objects
isEmpty(new Date());         // => true (Date objects have no enumerable properties)