back to Overview

_.isEmpty()

Returns true if the given string or list is null, undefined or empty (zero length).
Util module only.

Syntax Variants

_.isEmpty(s)
_.isEmpty(list)
_.isEmpty(s, ignoreWhitespace)

Parameters

s
the string to check. May be null or undefined.
list
the list to check. May be null or undefined.
ignoreWhitespace
if true and a string was given, isEmpty will also return true if the string contains only whitespace.
(return value)
true if empty, false otherwise

Description

Returns true if the given string or list is null, undefined or empty (zero length). If the second argument is true, the function will ignore whitespace in the string.

Example

Checking empty

_.isEmpty('abc');  // returns false
_.isEmpty('');   // returns true
_.isEmpty(null); // returns true
_.isEmpty(' '); // returns false
_.isEmpty(' ', true); // returns true

_.isEmpty([1, 2]); // returns false
_.isEmpty([]);     // returns true

Comments

comments powered by Disqus

back to Overview

Functions