闭包 能够访问其他函数作用域里变量的函数为一个闭包 用法: 变量私有化, 外部函📚能够访问内部变量 变量留在内存中,不能销毁 减少全局变量的使用 function counter() { let a= 1; function add() { a++; console.log(a) } return add; } let f1=counter(); cosole.log(a) // 报错 f1(); //2 f1(); //3