A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/javascript/lodash-_-isempty-method/ below:

Lodash _.isEmpty() Method - GeeksforGeeks

Lodash _.isEmpty() Method

Last Updated : 09 Jan, 2025

Lodash _.isEmpty() method checks if the value is an empty object, collection, map, or set. Objects are considered empty if they have no own enumerable string keyed properties. Collections are considered empty if they have a 0 length. Similarly, maps and sets are considered empty if they have a 0 size.

Syntax:
_.isEmpty(value);

Parameters:

Return Value:

Example 1: In this example, the _.isEmpty() method returns true as null is an empty value itself which does not hold any value.

javascript
// Defining Lodash variable
const _ = require('lodash');
let val = null;

// Checking for Empty Value
console.log("The Value is Empty :" + _.isEmpty(val))

Output:

The Value is Empty : true

Example 2: In this example, the _.isEmpty() method returns true as the length of the array is zero.

javascript
// Defining Lodash variable
const _ = require('lodash');

let val = []

console.log("The Value is Empty :" + _.isEmpty(val))

Output:

The Value is Empty : true

Example 3: In this example, the _.isEmpty() method returns true for both of the Boolean values.

javascript
const _ = require('lodash');

let val1 = true;
let val2 = false;

// Checking for Empty Value
console.log("The Value is Empty :" + _.isEmpty(val1))
console.log("The Value is Empty :" + _.isEmpty(val2))

Output:

The Value is Empty : true


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4