Skip to content

isEmpty

isEmpty(value): boolean

判断值是否为空

检查一个值是否为 null、undefined、空字符串、空数组或空对象

Parameters

NameTypeDescription
valueunknown要检查的值

Returns

boolean

如果值为空,返回 true;否则返回 false

Example

ts
isEmpty('');         // true
isEmpty(null);       // true
isEmpty(undefined);  // true
isEmpty([]);         // true
isEmpty({});         // true
isEmpty(0);          // false
isEmpty(false);      // false
isEmpty('0');        // false

Released under the MIT License.