标签:ISE ber key str lan def define 对象 nan
//是否为空
/**
* null undefined NaN false " " {} [] 为空
* 为空 true 不为空 false
* @param {*} value 参数
*
*/
isEmpty(value) {
let a = false;
if (Object.prototype.toString.call(value) == "[object Array]") {
a = value.length == 0 ? true : false;
} else if (Object.prototype.toString.call(value) == "[object Object]") {
a = Object.keys(value).length == 0 ? true : false;
} else if (Object.prototype.toString.call(value) == "[object String]") {
a = value.replace(‘/s‘, "").length == 0 ? true : false;
} else if (Object.prototype.toString.call(value) == "[object Number]") {
a = isNaN(value) ? true : false;
} else if (Object.prototype.toString.call(value) == "[object Null]") {
a = true;
} else if (Object.prototype.toString.call(value) == "[object Undefined]") {
a = true;
} else if (Object.prototype.toString.call(value) == "[object Boolean]") {
a = value ? false : true;
}
return a;
}
标签:ISE ber key str lan def define 对象 nan
原文地址:https://www.cnblogs.com/chendada/p/13214765.html