javascript中===和==的区别

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    
    <script type="text/javascript">
        // === 和 ==
        // === (判断更加严格)
        // 先会判断两边的表达式类型是否相同,如果相同再判断值
        // 如果类型不相同,直接返回 false
        // console.log(null === undefined); // false

        // == 存在数据类型的 隐式转换
        // console.log(null == undefined); // true
        // console.log(0 == "0"); // true
        // console.log(0 == ""); // true
        // console.log(123 == "123"); // true

        // 如果转换为布尔值:
        console.log(!!0);
        console.log(!!"");
    </script>
</body>
</html>

 

posted @ 2016-09-28 22:13  萧诺  阅读(159)  评论(0编辑  收藏  举报