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

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

<script>
var x = "Hello";
var x = 5;
document.getElementById("demo").innerHTML = typeof x;
</script>

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