typeof 运算符返回一个用来表示表达式的数据类型的字符串。
可能的字符串有:"number"、"string"、"boolean"、"object"、"function" 和 "undefined"。
一个很简单的例子
<html>
<head>
<script language="JavaScript">
var a=function(){
alert("This is in the function of a");
}
document.writeln("返回string,typeof('aa')=="+typeof('aa'));
document.writeln("<br/>返回number,typeof(8)=="+typeof(8));
document.writeln("<br/>返回boolean,typeof(true)=="+typeof(true));
document.writeln("<br/>返回object,typeof(document.getElementById('div'))=="+typeof(document.getElementById('div')));
document.writeln("<br/>返回undefined,typeof(cc)=="+typeof(cc));
document.writeln("<br/>返回function,typeof(a)=="+typeof(a));
</script>
</head>
<body>
<div id="div"></div>
</body>
</html>