关于JS中的数据类型

来源:互联网 发布:淘宝军工手机怎么样 编辑:程序博客网 时间:2024/05/29 06:29
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>


<body>
</body>
</html>
<script>
var a="hxsd";
var b=12314;
var c;
var d=true;


function run(){};


var oDiv=document.getElementById('box');


var arr=[a,b,c];


//tpyeof  6种


//alert(typeof a);//string
//alert(typeof b); //number
//alert(typeof c);//undefined
//alert(typeof d);//boolean
//alert(typeof run);//function


//alert(typeof document.body); //object
//alert(typeof oDiv); //null 也是 object
//alert(typeof arr); //数组 也是 object


//-------------------------------------------




/*
alert(c);  //undefined
if(c==undefined){ //直接判断c的值
alert("ok");
};*/




//tpyeof的6种类型,也是字符串,在判断语句当中,应该加上" "


//alert(typeof c);


if(typeof c=="undefined"){//判断c的“值的类型”
alert("ok")
}




</script>