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

作用域 #3

Open
qinxiaocha opened this issue Feb 9, 2022 · 0 comments
Open

作用域 #3

qinxiaocha opened this issue Feb 9, 2022 · 0 comments

Comments

@qinxiaocha
Copy link
Owner

qinxiaocha commented Feb 9, 2022

需要先了解:
1.函数的作用域在定义的时候就已经决定了,不是在使用的时候才决定;
2.当访问某个变量的时候,会在当前上下文虚寻找,然后会在父级作用域序号,一直到全局上下文,多个上下文形成的链表,我们叫做作用域。
3.作用域分两个阶段:创建时和激活时
1)创建时,根据函数的作用域在定义时就已经决定时,会有个scoped属性,这个属性保存了所有的父变量到其中;
2)激活时,会把当前作用域添加到最前端。[VO].concat(scoped)

来源:mqyqingfeng/Blog#6

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