个人练习,代码如下:
function myTypeof(o,type){
const types = {
'string': true,
'number': true,
'symbol': true,
'bigint': true,
'function': true,
'boolean': true,
'undefined': true,
'null': false,
'array': false,
'object': false,
}
let k = Object.prototype.toString.call(o).toLowerCase().slice(8,-1)
return types[k]?k:'object'
}
标签:function,false,object,typeof,手写,true,types From: https://www.cnblogs.com/justin999/p/17441895.html