typeof([1,2,3])
'object' //我想要的是Array 不够精准
Object.prototype.toString.call([1,2,3])
'[object Array]'
Object.prototype.toString.call(1)
'[object Number]'
Object.prototype.toString.call(null)
'[object Null]'
Object.prototype.toString.call(undefined)
'[object Undefined]'
Object.prototype.toString.call('1')
'[object String]'
typeof判断数据类型不精准? 试试这个
于 2022-02-08 10:35:14 首次发布