xxxxxxxxxx
<!DOCTYPE html>
<html>
<title>JavaScript typeof运算符示例 - 基础教程(div.cn)</title>
<body>
<h1> JavaScript typeof运算符</h1>
<p> typeof运算符返回变量或表达式的类型:</p>
<script>
document.write(
typeof "" + "<br>" +
typeof "Json" + "<br>" +
typeof "42" + "<br>" +
typeof 42 + "<br>" +
typeof true + "<br>" +
typeof false + "<br>" +
typeof undefined + "<br>" +
typeof null + "<br>" +
typeof {name:"Json", age:22} + "<br>" +
typeof [2, 4, 6, 8] + "<br>" +
typeof function myFunc(){}
);
</script>
<p> <b>注意:</b> <b> typeof </b>运算符为数组返回"object",因为在JavaScript数组中是对象。</p>
</body>
</html>