Thursday, October 16, 2025
HomeLanguagesJavascriptCollect.js isEmpty() Method

Collect.js isEmpty() Method

The isEmpty() method is used to check the given collection is empty or not and returns the corresponding boolean value.

Syntax:

collect(array).isEmpty()

Parameters: The collect() method takes one argument that is converted into the collection and then isEmpty() method is applied on it.

Return Value: This method checks the given collection is empty or not and returns the corresponding boolean value.

Below example illustrate the isEmpty() method in collect.js:

Example 1:




const collect = require('collect.js');
  
let arr = [];
  
const collection = collect(arr);
  
const isemp = collection.isEmpty();
  
console.log(isemp);


Output:

true

Example 2:




const collect = require('collect.js');
  
const collection = collect({});
  
const isemp1 = collection.isEmpty();
  
console.log(isemp1);
  
const collection1 = collect([10, 20, 30]);
  
const isemp2 = collection1.isEmpty();
  
console.log(isemp2);


Output:

true
false
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS