标签:null pre 变量 通用 str func new eof number
Object.prototype.toString.call(true)
"[object Boolean]"
Object.prototype.toString.call(1)
"[object Number]"
Object.prototype.toString.call(null)
"[object Null]"
Object.prototype.toString.call(undefined)
"[object Undefined]"
Object.prototype.toString.call(‘ndefined‘)
"[object String]"
Object.prototype.toString.call([])
"[object Array]"
Object.prototype.toString.call({})
"[object Object]"
Object.prototype.toString.call(alert)
"[object Function]"
typeof undefined
"undefined"
typeof true
"boolean"
typeof 1
"number"
typeof ‘sds‘
"string"
typeof alert
"function"
typeof null
"object"
typeof []
"object"
typeof {}
"object"
var a = new String(‘123‘);
console.log(a);
console.log(Object.prototype.toString.call(a));
console.log(typeof a);
String {"123"}
[object String]
object
js变量类型判断 严格通用 Object.prototype.toString.call()
标签:null pre 变量 通用 str func new eof number
原文地址:https://www.cnblogs.com/ysk123/p/9996034.html