准确判断数据具体类型.终极解决方案
字面意思调用Object.prototype.toString 的同时用 call 改变此方法的内部this指向
借助Object.prototype上的 toString 方法
const arr = []
const obj = {}
const tempnull = null
const fn = function () { }
const str = '1'
const num = 1
console.log(Object.prototype.toString.call(arr));
console.log(Object.prototype.toString.call(obj));
console.log(Object.prototype.toString.call(tempnull));
console.log(Object.prototype.toString.call(fn));
console.log(Object.prototype.toString.call(str));
console.log(Object.prototype.toString.call(num));
[object Array]
[object Object]
[object Null]
[object Function]
[object String]
[object Number]