js 判断是数组还是对象还是字符串
let data = [1,2,3,4,5];if(Object.prototype.toString.call(data ) === ‘[object Array]’){console.log(‘数据为数组类型’)}if(Object.prototype.toString.call(data ) === ‘[object object]’){console.log(‘数据为对象类型’)}
·
let data = [1,2,3,4,5];
if(Object.prototype.toString.call(data ) === ‘[object Array]’){
console.log(‘数据为数组类型’)
}
if(Object.prototype.toString.call(data ) === ‘[object Object]’){
console.log(‘数据为对象类型’)
}
if(Object.prototype.toString.call(data ) === ‘[object String]’){
console.log(‘数据为字符串类型’)
}
更多推荐
已为社区贡献3条内容
所有评论(0)