代码示例:(标识:js_typeof_all)
<!DOCTYPE html>
<html>
<body>

<h1>JavaScript 运算符</h1>

<h2>typeof 运算符</h2>

<p>typeof 操作符返回变量、对象、函数或表达式的类型:</p>

<p id="demo"></p>

<script>
document.getElementById("demo").innerHTML = 
"'Bill' 是 " + typeof "Bill" + "<br>" +
"3.14 是 " + typeof 3.14 + "<br>" +
"NaN 是 " + typeof NaN + "<br>" +
"false 是 " + typeof false + "<br>" +
"[1, 2, 3, 4] 是 " + typeof [1, 2, 3, 4] + "<br>" +
"{name:'Bill', age:19} 是 " + typeof {name:'Bill', age:19} + "<br>" +
"new Date() 是 " + typeof new Date() + "<br>" +
"function () {} 是 " + typeof function () {} + "<br>" +
"myCar 是 " + typeof myCar + "<br>" +
"null 是 " + typeof null;
</script>

</body>
</html>
运行结果: