-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
闭包 #4
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
闭包是有权访问另一个函数作用域中的变量的函数:当函数1向外暴露了可以改变内部局部变量的方法(内部匿名函数,外部函数2接受匿名函数,匿名函数作用域链在初始化时包含了函数1的变量对象,可以调用函数1所有的内部变量。一般函数执行完局部活动对象就会进行销毁,内存仅仅只会保存全局作用域,但函数1在执行完毕其活动对象也不会进行销毁,因为匿名函数的作用域链仍然在对其进行调用。(参考高程
可以读取函数内部的变量,让变量的值始终保持在内存中。栗子:实现函数curry化。
内存泄露。
The text was updated successfully, but these errors were encountered: