分享一个快速判断JS的对象到底是object还是数组还是函数的方法 function sum(){ } let arr = [1,2] let obj = {a:1} console.log(Object.prototype.toString.call(sum))//[object Function] console.log(Object.prototype.toString.call(arr))//[object Array] console.log(Object.prototype.toString.call(obj))//[object Object]
展开
6
评论
Ctrl + Enter