闭包的应用-概念:闭包就是能够读取其他函数内部变量的函数
function a() { var i = 0; function b() { alert(++i); } return b; } var c = a(); c();
- 闭包能够让变量的值始终保存在内存之中。- 闭包可以保护函数内的变量安全。