第333天 用js实现typeof的功能 作者:Indomi [我也要出题](http://web.haizlin.cn/interview/)
Activity
longhui520 commentedon Mar 14, 2020
vizoy commentedon Nov 18, 2020
wind8866 commentedon Mar 30, 2022
mohaixiao commentedon Jun 21, 2022
xiaoqiangz commentedon Sep 16, 2022
function myTypeOf(params) {
const result = Object.prototype.toString.call(params).slice(8, -1).toLowerCase()
let map = {
number: 'number',
array: 'Array',
function: 'Function',
undefined: 'undefined',
string: 'String',
object: 'Object',
symbol: 'Symbol',
null: 'Null',
boolean: 'Boolean'
}
return map[result]
}