//判断是不是数组
console.log(Object.prototype.toString.apply([])===‘[object Array]‘)
//判断是不是函数
console.log(Object.prototype.toString.apply(function(){})===‘[object Function]‘)
//判断是不是null
console.log(Object.prototype.toString.apply(null)===‘[object Null]‘)
//判断是不是undefined
console.log(Object.prototype.toString.apply(undefined)===‘[object Undefined]‘);
//判断是不是字符串
console.log(Object.prototype.toString.apply(‘str‘)===‘[object String]‘)
时间: 2024-10-29 09:32:28