博客
关于我
什么是javascript的闭包 和闭包的规则 特点
阅读量:341 次
发布时间:2019-03-04

本文共 1087 字,大约阅读时间需要 3 分钟。

???Closure?????????????????????????????????????????????????????????????????????????????????????????????????????????????????

??????????????????????????????????????????return????????????????????????????????????????????????

function f1() {    var week = "sunday";    function f2() {        console.log('???' + week);    }    return f2;}var ff = f1();ff(); // ??: ??? sunday

???????f2??????????????f1?????week?????f2?ff???????????????????????????????????????????????????????????????????????

?????

  • ?????????????????????????????????????????
  • ????????????????????????????????????????
  • ?????????????????????????????????????????
  • ?????

    ??????????????????????????????????????????????

    function t1(num) {    function t2() {        console.log("??" + num);    }    return t2;}var fa = t1(100);var fb = t1(200);fa(); // ??: ??100fb(); // ??: ??200

    ???????????t1?????????????fa?fb?????t1?????????????????num?????????????????????

    ????

  • ??????????????????????????????
  • ????????????????????????????????????
  • ?????????????????????????????
  • ?????????????????????????????????????????????????????????????????????????

    转载地址:http://vpke.baihongyu.com/

    你可能感兴趣的文章
    PHP设计模式:观察者模式
    查看>>
    php访问mysql(1)
    查看>>
    php详细学习1
    查看>>
    php语言优劣
    查看>>
    PHP语言最优雅的支付SDK扩展包
    查看>>
    PHP请求https域名发生segment fault段错误
    查看>>
    PHP读写XML文件
    查看>>
    PHP读写XML文件
    查看>>
    R&Python Data Science 系列:数据处理(3)
    查看>>
    php读取xml 数据库字段超长处理
    查看>>
    php课程 12-40 抽象类的作用是什么
    查看>>
    php课程 4-16 数组自定义函数(php数组->桶)
    查看>>
    PHP调用接口用post方法传送json数据
    查看>>
    php转化IP为整形
    查看>>
    php输出数据到csv文件
    查看>>
    php输出语句
    查看>>
    php运行原理详细说明
    查看>>
    php运行环境出现Undefined index 或variable时解决方法
    查看>>
    php进程通信
    查看>>
    R&Python Data Science 系列:数据处理(2)
    查看>>