<html>
<head>
<meta charset="utf-8">
<title>dingshiqi
</title>
<script>
var a=12;
//alert(typeof a);//number
a='ad';
//alert(typeof a);//string
a=true;
//alert(typeof a);//boolean
a=function()
{
alert(typeof a);
};
//alert(typeof a);//function
a=document;
//alert(typeof a);//object
var b;
alert(typeof b);//undefined
//undefined出现情况:
//1.真的没有定义
//2.没有给值
</script>
</head>
<body>
<div id="div1" style="width:200px;height:200px;background:red;"/>
</body>
</html>
javascript 变量类型
最新推荐文章于 2025-08-22 11:32:18 发布