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

    人生如戏,或实力或演技
  • 相关阅读:
    Nginx配置文件详解
    JVM调优—性能分析神器-JProfiler详解
    Navicat Premium 15破解
    Nginx配置反向代理,负载均衡,动静分离,高可用
    Nginx安装和常用命令
    Spring中ApplicationContextAware的作用
    java中发起http和https请求
    MySql高可用架构
    matlab画3维meshgrid/plot3/mesh/surf的用法
    如何规范地编写一个MATLAB函数文件
  • 原文地址:https://www.cnblogs.com/yang0902/p/5697994.html
Copyright © 2011-2022 走看看