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

    人生如戏,或实力或演技
  • 相关阅读:
    HTML5 API的威力
    国内独立博客发展的障碍
    中国天气 XWeahter 2.0.1.0 所有版本 下载地址 阿干 win7
    宿命轮回里的爱与恨
    广东一伙劫匪在抢劫银行时说了一句至理名言
    Android项目R文件丢失报错
    2010年8月29日周日_Creating a New Xcode Project_3
    2010年8月27日周五understanding ArcGIS Server_secured services_8.4
    2010年8月26日_TitleWindow_Flex控件
    组件类_BorderContainer1
  • 原文地址:https://www.cnblogs.com/yang0902/p/5697994.html
Copyright © 2011-2022 走看看