We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
作用域可以理解为上下文声明的变量和作用范围。js函数中的隐式属性[[scope]]存储的对象就是作用域,其中分为函数作用域和全局作用域。
当局部函数查找某一属性或方法时,如果当前作用域没查找到,就会向上查找上层作用域,直至全局作用域,这样就形成了作用域链。
function a() { function b() { var b = 234; console.log(a);// 123 console.log(glob);// 100 } var a = 123; b(); } var glob = 100; a();
a函数的作用域链: b函数的作用域链:
The text was updated successfully, but these errors were encountered:
No branches or pull requests
作用域
作用域可以理解为上下文声明的变量和作用范围。js函数中的隐式属性[[scope]]存储的对象就是作用域,其中分为函数作用域和全局作用域。
作用域链
当局部函数查找某一属性或方法时,如果当前作用域没查找到,就会向上查找上层作用域,直至全局作用域,这样就形成了作用域链。
a函数的作用域链:
![image](https://user-images.githubusercontent.com/13798469/62420203-f90f0d00-b6c0-11e9-9fa4-739d293a70e9.png)
![image](https://user-images.githubusercontent.com/13798469/62420253-b6016980-b6c1-11e9-9a7f-bf58b1f586c9.png)
b函数的作用域链:
The text was updated successfully, but these errors were encountered: