Skip to content

@longmo-utils/common / isEmpty

Function: isEmpty()

ts
function isEmpty(str): boolean;

检查字符串是否为空或只包含空白字符

Parameters

ParameterTypeDescription
strstring | null | undefined输入字符串

Returns

boolean

如果为空或只包含空白字符返回 true

Example

ts
isEmpty('') // true
isEmpty('   ') // true
isEmpty(null) // true
isEmpty(undefined) // true
isEmpty('hello') // false

Released under the MIT License.