zoukankan      html  css  js  c++  java
  • 预解析

    预解析:预先解析一些东西;
        变量的定义会提前到我们能理解的最前面;
        预解析的作用范围: 会找本作用域内;
        函数的也会预解析;
        
                  1.     function show(a){
                               alert(a);  //function()
                               var s=a();  //弹a, s为undefined(函数a()没有返回值);
                               return function(){
                                   alert(s);}    //undefined
                                }
                               function a(){
                                   alert('a');
                                }
                                show(a)//执行到return,结果function,弹a
                                alert(show(a));//结果function,弹a,return后面function
                                show(a)()//执行return函数,结果function,弹a ,undefined
                                alert(show(a)());//执行return函数返回值,结果function,弹a ,undefined,undefined                

              

         2.  function step(a){
                            return function(x){

                                  return x + a++;}
                            }
                            var a = step(10);
                            var b = step(20);
                            alert(a(12));//a(10)(12),22
                            alert(b(12));//b(20)(12),32

    人生如戏,或实力或演技
  • 相关阅读:
    表单重复提交问题
    Win8.1卸载64位Oracle Database 11g的详细图文步骤记录
    A1084. Broken Keyboard (20)
    A1088. Rational Arithmetic (20)
    A1089. Insert or Merge (25)
    A1034. Head of a Gang (30)
    A1013. Battle Over Cities (25)
    A1030. Travel Plan (30)
    A1003. Emergency (25)
    A1076. Forwards on Weibo (30)
  • 原文地址:https://www.cnblogs.com/yang0902/p/5697994.html
Copyright © 2011-2022 走看看