非空判断

const isEmpty = (obj: any) => { let isEmpty = false if (obj === undefined || obj === null || obj === '') { isEmpty = true } else if (Array.isArray(obj) && obj.length === 0) { isEmpty = true } else if (obj.constructor === Object && Object.keys(obj).length === 0) { isEmpty = true } return isEmpty }
posted @ 2022-01-12 10:29  小闫先生  阅读(62)  评论(0)    收藏  举报