精确判断数据类型的方法函数 var type = function(data) { let toString = Object.prototype.toString; let dataType = toString.call(data) .replace(/\[object\s(.+)\],"$1"/) .toLowerCase(); return dataType.split(' ')[1].split(']')[0]; } console.log(type('111'));