美文网首页
typeof 返回的6种数据类型有

typeof 返回的6种数据类型有

作者: duJing | 来源:发表于2017-01-04 15:21 被阅读172次
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
/*
* typeof 返回的6种数据类型有:
* “boolean”——布尔值
* “string”——字符串
* “number”——数值
* “object”——对象或者null;
* “function”——函数
* “undefined” ——未定义
* PS : 返回的值永远是字符串
* */

window.onload = function () {
/*var a = 10;
alert(typeof a); // "number"*/


/*var a = '10';
alert(typeof a); // "string"*/


/*var a = false;
alert(typeof a); // "boolean"*/


/*var a = 10;
alert(typeof b); // "undefined"*/


/*var a = null; // {},null,[]
alert(typeof a); // "object"*/


var a = function () {
};
alert(typeof a); // "function"


}
</script>
</body>
</html>

相关文章

网友评论

      本文标题:typeof 返回的6种数据类型有

      本文链接:https://www.haomeiwen.com/subject/yjgovttx.html