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

    人生如戏,或实力或演技
  • 相关阅读:
    js es6遍历对象的6种方法
    MySQL、Redis、MongoDB网络抓包工具
    SSE图像算法优化系列三十一:Base64编码和解码算法的指令集优化(C#自带函数的3到4倍速度)。
    设置EntityFramework中decimal类型数据精度问题(EF默认将只会保留到2为精度)
    IIS资料
    RabbitMQ
    微信公众平台生成带场景参数二维码
    .net Core资料
    微信字体放大影响布局的处理
    VirtualBox虚拟机下安装Win10性能优化
  • 原文地址:https://www.cnblogs.com/yang0902/p/5697994.html
Copyright © 2011-2022 走看看