typeof可以返回变量的类型,返回值为字符串,其值有
“undefined”
“boolean”
“string”
“number”
“object”
“function”
而 typeof(null)会返回object
举个列子:
1 2 3 4 |
var str="abc"; if(typeof str ==="string"){ alert('我是字符串'); } |
转载请注明:PHP笔记 » JS中typeof的用法