<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>closure</title>
    <script type="text/javascript">
    function fn(){
        var n = '123';
        return function(){
            console.log(n);
        }
    }
    var a = fn();//把返回值匿名函数给a
    a();//调用a就是调用fn中返回的匿名函数
    //本例已经通过验证
    </script>
</head>
<body>
    
</body>
</html>

js原生设计模式——2面向对象编程之闭包1的更多相关文章

  1. js原生设计模式——2面向对象编程之闭包2

    <!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8&qu ...

  2. js原生设计模式——2面向对象编程之继承—多继承

    1.单对象克隆 <!DOCTYPE html><html lang="en"><head>    <meta charset=" ...

  3. js原生设计模式——2面向对象编程之继承—原型继承(类式继承的封装)

    <!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8&qu ...

  4. js原生设计模式——2面向对象编程之继承—new+call(this)组合式继承

    <!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8&qu ...

  5. js原生设计模式——2面向对象编程之继承—call(this)构造函数式继承

    <!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8&qu ...

  6. js原生设计模式——2面向对象编程之继承—new类式继承

    <!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8&qu ...

  7. js原生设计模式——2面向对象编程之js原生的链式调用

    技巧点:对象方法中返回当前对象就可以链式调用了,即方法中写return this; <!DOCTYPE html><html lang="en"><h ...

  8. js原生设计模式——10适配器模式之参数适配器

    原理:参数适配器说白了就是给出要带入数据字段的对应字段的默认值,一旦数据字段值不足,就取默认值补足. [写法一]:直接返回 <!DOCTYPE html><html lang=&qu ...

  9. js原生设计模式——8单例模式之简约版属性样式方法库

    <!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8&qu ...

随机推荐

  1. .h .m切换

    快捷键是:command + control +[↑|↓]

  2. 转:Loadrunner上传文件解决办法(大文件)

    最近再做一个跟海量存储相关的项目测试,需要通过LR模拟用户大量上传和下载文件,请求是Rest或Soap,同时还要模拟多种大小尺寸不一的文件 通常情况下,都是使用简单的post协议即可: 方法一: we ...

  3. Python3基础 定义无参数无返回值函数 调用会输出hello world的函数

    镇场诗: 诚听如来语,顿舍世间名与利.愿做地藏徒,广演是经阎浮提. 愿尽吾所学,成就一良心博客.愿诸后来人,重现智慧清净体.-------------------------------------- ...

  4. PAT (Advanced Level) 1080. Graduate Admission (30)

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...

  5. Android开发学习资源

    https://developer.android.google.cn/training/index.html

  6. cnn 文章

    http://www.cnblogs.com/fengfenggirl/p/cnn_implement.html http://www.2cto.com/kf/201603/493553.html h ...

  7. [iOS]C语言技术视频-04-程序循环结构(while{})

    下载地址: 链接: http://pan.baidu.com/s/1o6imQ4U 密码: imuy

  8. $(srctree) is not clean, please run 'make mrproper'

    在使用make menuconfig重新配置后,再编译kernel时常会遇到这样的问题: Using /home/likewise-open/BJS/lisa.liu/code/sprdroid4.0 ...

  9. 关于bool和BOOL的区别

    1.类型不同: BOOL是int类型,bool是布尔类型 2.长度不同: BOOL长度是其环境来定,一般是4个字节,因为其是int类型;bool长度为一个字节 3.取值不同: BOOL取值是FALSE ...

  10. Inside dependency property

    依赖属性的定义,分为3步(以PresentationFramework中的System.Windows.Controls.Button为例) 1.  声明依赖属性 public static read ...