I'm sure you'll be confused about the scope, scope chain, and variable declaration promotion concepts when you get started with JavaScript.Javascript ScopesIn Javascript, there are only local scopes and global scopes. Instead, only functions can
ObjectiveIn the 12th chapter, in the description of variable objects, we already know that the data (variables, function declarations, and function parameters) of an execution context are stored as attributes in the variable object.
We also know
In some C-like programming languages, each piece of code within the curly braces has its own scope, and the variables are not visible outside the code snippet that declares them (i.e. we cannot directly access the variables declared within the code
in the 12th chapter of the description of variable objects, we already know that the data of an execution context (variables, function declarations, and formal parameters of functions) is stored as attributes in the variable object. We also know
This is a creation in
Article, where the information may have evolved or changed.
1. Block
The block is a pair of curly braces that enclose the declaration and statement. Block = "{" {statement ";"} "}".
In addition to the explicit source block,
PrefaceIn the description of the variable object in Chapter 12th, we already know that the data of the execution context (variables, function declarations, and function parameters) are stored in the variable object as attributes.
At the same time,
JavaScript variable declaration elevation (hoisting) JavaScript's variable declarations have a hoisting mechanism, and the JavaScript engine, when executed, promotes the declaration of all variables to the front of the current scope .Look at a piece
1. BlockThe block is a pair of curly braces that enclose the declaration and statement. Block = "{" {statement ";"} "}".In addition to the explicit source block, there is an implicit block:
The full domain block contains all
http://www.cnblogs.com/wolf-lifeng/p/3156936.html2.3 Global Scope 2.3.1 OverviewThe global scope is the largest namespace scope, unlike the user-defined namespace scope, where the global scope does not need to be defined, and it naturally exists in
Deep understandingJavaScriptSeries ( -): Scope chain(Scope Chain)ObjectiveIn the 12th chapter of the description of variable objects, we already know that the data of an execution context (variables, function declarations, and formal parameters of
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.