let data = [1,2,3,4,5];
if(Object.prototype.toString.call(data ) === ‘[object Array]’){
console.log(‘数据为数组类型’)
}
if(Object.prototype.toString.call(data ) === ‘[object Object]’){
console.log(‘数据为对象类型’)
}
if(Object.prototype.toString.call(data ) === ‘[object String]’){
console.log(‘数据为字符串类型’)
}
/**
* 判断字符串是否不为空,包括判断null/undefined
* @param {Object} str
*/
export function isNotEmpty(str:Object) {
if(typeof(str)=="undefined" || ""+str =="undefined" || str == null) {
return false;
}
var t = str.toString().trim();
if(t == "" || t == "null" || t == "undefined") {
return false;
}
return true;
}