The value to check.
true
if the value is empty, otherwise false
.
// Example 1: Checking null or undefined
console.log(isEmpty(null)); // true
console.log(isEmpty(undefined)); // true
// Example 2: Checking objects
console.log(isEmpty({})); // true
console.log(isEmpty({ key: 'value' })); // false
// Example 3: Checking arrays
console.log(isEmpty([])); // true
console.log(isEmpty([1, 2, 3])); // false
// Example 4: Checking strings
console.log(isEmpty('')); // true
console.log(isEmpty('Hello, World!')); // false
// Example 5: Checking numbers
console.log(isEmpty(0)); // true
console.log(isEmpty(42)); // false
Checks if the given value is empty.
This function determines whether a value is considered "empty." A value is deemed empty if:
null
orundefined
.0
.