zoukankan      html  css  js  c++  java
  • in window js 未定义和undifined的区别

    浏览器报错:未定义和undifined不是同一概念,前者是没有申明,后者是没有赋值。


    1:

    <html>
        <body>
            <script>
                if(!("a" in window)){
                    var a = 1;
                }
                alert(a);//undifined

                function b(){
                    var c = 2;
                }
                alert(b);//函数b
                //alert(c);//报错 c未定义
                alert("c" in window);//false
                alert(c);//报错 c未定义
            </script>
        </body>
    </html>

    2:

    <html>
        <body>
            <script>
                var a = 1
                b = function a(x){
                    x && a(--x);
                };
                alert(a);//1
            </script>
        </body>
    </html>

    3:

    <html>
        <body>
            <script>
                if(!("" in window)){
                    var a = 1;
                }
                alert(a);//1
            </script>
        </body>
    </html>

    4:

    <html>
        <body>
            <script>
                var d;
                alert(d);//undifined
                var a = 1;
                b = function a(x){
                    x && a(--x);
                };
                alert(a);//1
            </script>
        </body>
    </html>




    @江西-小若 总结

  • 相关阅读:
    golang_并发安全: slice和map并发不安全及解决方法
    什么情况下需要用到互斥锁sync.Mutex?
    使用Charles进行HTTPS抓包
    centos6 yum 源失效 404,终于解决了
    GOMAXPROCS你设置对了吗?
    容器资源可见性问题与 GOMAXPROCS 配置
    gflags 使用方式
    分布式训练问题
    NCCL常用环境变量
    git 常用命令
  • 原文地址:https://www.cnblogs.com/pangblog/p/3320015.html
Copyright © 2011-2022 走看看