web-utils-super
Version:
前端函数库
19 lines (17 loc) • 556 B
JavaScript
/**
* @desc: 判断是否为空(是否为空字符串、null、undefined、{}、[]、false)
* @param {String | null | undefined | Object | Array | Boolean} value
* @return {Boolean}
*/
function isEmpty(value) {
return (
value === null ||
value === false ||
value === "" ||
(typeof value === 'object' && Object.keys(value).length === 0) ||
(Array.isArray(value) && value.length === 0) ||
(typeof value === 'string' && value.trim() === "") ||
typeof value === 'undefined'
);
}
module.exports = isEmpty;