摘要:
function mark(p, level){ if(level >3){ return ; } if(typeof p == "object" && p != null && p.marked == undefined){ p.marked = true; console.log(p); for 阅读全文
随笔档案-2017年07月
函数式编程,闭包,作用域,全局变量
2017-07-02 21:07 by Dirichlet, 552 阅读, 收藏, 编辑
摘要:
一个函数返回它内部定义的一个函数,就产生了一个闭包,闭包不仅包括被返回的函数 ,还包括这个函数的定义环境。上面例子中,generateClosure内部的函数get被外部的变量counter引用时,counter和generateClosure的局部变量就构成了一个闭包。 上面例子generateC 阅读全文