JavaScript数据类型

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Typeof</title>
    <script>

        //对象不存在时返回null
        //变量未被赋值是undefined

        var test1 = "abcdef";
        var test2 = 123;
        var test3 = true;
        var test4 = {};
        var test5 = [];
        var test6;
        var test7 = {"abcdef": 123};
        var test8 = ["abac", 123];
        function test9(){return "avc"};
        var test10 = null;

        console.log(typeof test10)
        //NaN是无法表示的数值,无法自身比较NaN != NaN, NaN与任何东西都不相等
        //判断NaN,任何不是数字的值传给isNaN返回的结果都是true
        var myNum;
        if (isNaN(myNum)){
            myNum = 0;
        }
        alert(myNum);

        //Infinity指的是超过数据上限或这下限的值

        if (99 == "99"){
            console.log("A number equals a string");
        } else {
            console.log("No way a number equals a strings");
        }

    </script>
</head>
<body>

</body>
</html>

 

posted @ 2018-07-15 16:19  道高一尺  阅读(134)  评论(0编辑  收藏  举报