typeObj(obj) { const typeMap = { ‘[object Array]‘: ‘Array‘, ‘[object Object]‘: ‘Object‘, ‘[object String]‘: ‘String‘, ‘[object Number]‘: ‘Number‘ } const typeStr = Object.prototype.toString.call(obj); return typeMap[typeStr] || ""; }
2021-12-19 13:59:45
typeObj(obj) { const typeMap = { ‘[object Array]‘: ‘Array‘, ‘[object Object]‘: ‘Object‘, ‘[object String]‘: ‘String‘, ‘[object Number]‘: ‘Number‘ } const typeStr = Object.prototype.toString.call(obj); return typeMap[typeStr] || ""; }