typeof操作符:
- ECMAScript的變量是鬆散類型的,而typeof操作符可以檢測變量的數據類型
- typeof是一個操作符,不是函數
- typeof操作符返回值爲字符串,比如
- 當值未定義時,返回"undefined"
- 當值爲布爾時,返回"boolean"
- 當值是字符串時,返回"string"
- 當值是數值時,返回"number"
- 當值是對象或null時,返回"object"
- 當值是函數時,返回"function"
var message = "some string";
alert(typeof message); //"string"
alert(typeof 10); //"number"