js如何判断一个变量的数据类型

let str = 'abccccccdddww'

function getType(variable) {
    return Object.prototype.toString.call(variable).replace(/\[object\s|\]/g, '')
}

console.log(getType(str))// string

posted on 2022-03-28 21:22  GameCat  阅读(21)  评论(0编辑  收藏  举报

导航