Skip to content
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

8. 作用域、作用域链、闭包 #8

Open
maxlxq opened this issue Dec 10, 2019 · 0 comments
Open

8. 作用域、作用域链、闭包 #8

maxlxq opened this issue Dec 10, 2019 · 0 comments

Comments

@maxlxq
Copy link
Owner

maxlxq commented Dec 10, 2019

作用域
在JS中,分为全局作用域和局部作用域。
全局作用域中的全局变量能被任何函数或方法访问,在JavaScript中默认是可以被修改的。
局部作用域包括函数作用域、块级作用域。

作用域链
如果一个变量在当前作用域中使用,当前作用域未找到变量的定义,就会向父级作用域寻找,依次向父级寻找,找到则直接供当前作用域使用,未找到则抛出异常ReferenceError

闭包

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant