const isEmpty = (val) => {
if (val instanceof Blob)
return !val.size
// JSON.stringify(undefined) => undefined
// JSON.stringify(null) => 'null'
// JSON.stringify(NaN) => 'null'
// JSON.stringify([]) => '[]'
// JSON.stringify({}) => '{}'
// 注意:JSON.stringify(new Blob(['123'])) => '{}'
return [undefined, 'null', '""', '[]', '{}'].includes(JSON.stringify(val))
}
重复写真麻烦,想到新方法先记录下来,每次都回想真折磨
标签:stringify,判断,undefined,val,值为,JS,JSON,null From: https://www.cnblogs.com/hcbin/p/16744396.html