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>




    @江西-小若 总结

  • 相关阅读:
    Linux 重新挂载分区的方法
    SQL复习三(子查询)
    SQL复习四(完整性约束)
    SQL 复习二(数据查询语言)
    SQL复习一(基础知识)
    在windos 环境下安装
    tt程序分析(一)
    单例模式Singleton
    用命令行使用soot反编译生成jimple
    在win10环境下安装eclipse mars版本
  • 原文地址:https://www.cnblogs.com/pangblog/p/3320015.html
Copyright © 2011-2022 走看看