判断类型
1 let objType = {} 2 'Array Date RegExp Object Error'.split(' ').forEach(e => objType['[object ' + e + ']'] = e.toLowerCase()) 3 function type(obj) { 4 if(obj==='null'){ 5 return String(obj) 6 } 7 return typeof obj === 'object' ? objType[Object.prototype.toString.call(obj)] : typeof obj 8 }