2018-07-23typeof运用

2018-07-23  本文已影响0人  菜鸟亿个

<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>数据类型</title>
<script>
var age = 20; //number 数值类型
// alert(typeof(age));
document.write("变量 var age =20 数据类型是 :"+typeof(age) +"
"); //将write函数括号内的值显示到html页面

    var user = "小明";  //string 字符串类型
    document.write("变量 var user = '小明' 数据类型是 :" + typeof (user)  +"<br/>");

    var sex = true;  //boolean 布尔类型
    document.write("变量 var sex = true 数据类型是 :" + typeof (sex)  +"<br/>");

    var is;
    document.write("变量 var is; 数据类型是 :" + typeof (is)  +"<br/>");

    var isnull = null;  //object 对象类型
    document.write("变量 var isnull = null :" + typeof (isnull)  +"<br/>");

</script>

</head>
<body>

</body>
</html>

上一篇 下一篇

猜你喜欢

热点阅读