js通用检测数据类型方法
function getDataType(obj) { let type = typeof obj
// 先判断是否为基础数据类型,直接返回 if (type !== 'object') return type;
// 对于typeof返回结果是'object'的,在进行如下的判断,正则返回结果 return Object.prototype.toString.call(obj).replace(/^\[object (\S+)\]$/, '$1'); }
function getDataType(obj) { let type = typeof obj
// 先判断是否为基础数据类型,直接返回 if (type !== 'object') return type;
// 对于typeof返回结果是'object'的,在进行如下的判断,正则返回结果 return Object.prototype.toString.call(obj).replace(/^\[object (\S+)\]$/, '$1'); }