/*
js among Each function is an execution environment
Function call function will enter the new execution environment, and then return to the current Scope chain : You can access and modify external variables in the internal scope
You cannot modify or access internal variables in an external scope
*/
var a = 1; function outer(){
b = a;
function inner(){
c = b;
alert(c);
}
inner();
alert(b);
//alert(c); // You can't visit c c Is a variable in an internal scope
}
outer();
alert(a);

JavaScript More articles on the scope chain of

  1. On JavaScript( Four )—— Scope chain and declaration ahead of time

    Preface : It's graduation season , Tens of thousands of student party began to enter the society , Farewell to the ivory tower like school life . Often at every turning point of life , Emotional , deep feeling , All kinds of wonderful summaries of the past , Looking forward to the future . meanwhile , Also let many old “ garden ” After reading these ...

  2. Explain from scratch JavaScript The concept and use of scope chain in

    Explain from scratch JavaScript The concept and use of scope chain in introduction Text One . execution environment Two . Scope chain 3、 ... and . Block level scope Four . Other situations 5、 ... and . summary Conclusion introduction Like it first , Look at the blog again , It's easy to pay attention to . WeChat official account search ...

  3. understand JavaScript Of the scope chain

    The last article introduced Execution Context Three important parts of :VO/AO,scope chain and this, And introduced in detail VO/AO stay JavaScript Performance in code execution . Let's take a look at Exec ...

  4. understand JavaScript The relationship between scope chains in

    javascript There's a lot of chaos in the relationship . A scope chain is a one-way chain relationship , It's simple and clear :this The calling relation of mechanism , It's a little complicated : And about archetypes , It is prototype.proto and constructor The triangle of ...

  5. javascript Scope chain of -07

    Review scope In the last section we talked about scope : It refers to the range of variables that can be accessed , He specifies how to find variables , And determine the access rights of the current executing code to variables : Also, static scope is lexical scope , It's the compilation phase that determines the reference to the variable ( Determined by the location of the program definition , and ...

  6. JavaScript series ---- Scope chains and closures

    1. Scope chain 1.1. What is scope Talking about scope chains , We have to start with scope . Because the so-called scope chain is composed of multiple scopes . that , What is scope ? 1.1.1 Scope is the execution environment of a function during execution . Every time ...

  7. javascript Scope chain of -10

    Preface stay < execution environment > It says , When JavaScript When the code executes a piece of executable code , The corresponding execution context will be created (execution context). The variable object (Variable object,VO ...

  8. From the perspective of function scope and block level scope javascript Of the scope chain

    stay ES6 Before ,javascript Only global scope and function scope . A scope is the scope that a variable defines and can be accessed . That is, if a variable is defined globally (window) On , So this variable can be accessed anywhere , If this ...

  9. javascript From the perspective of scope chain, closure

    Closure A closure is a function that can access variables defined by an external function . Why? ? When accessing a variable , The interpreter first looks for the identifier in the current scope , If not found , Go to the parent scope , Until the identifier of the variable is found or the parent scope no longer exists , That's what it does ...

Random recommendation

  1. Reading ASP.NET 5 &amp; MVC6 series

    Most of the content of this series comes from the reading of Microsoft source code and the Internet , Most of the test code is based on VS RC Version for testing . Reading ASP.NET 5 & MVC6 series (1):ASP.NET 5 brief introduction Reading ASP.NET 5 ...

  2. Linux File count

    1. The number of files in the current directory ls -l |grep "^-"|wc -l 2. The tree of the current directory ls -l |grep "^d"|wc -l 3. The current number of directory files contains ...

  3. Read Excel file from C#

    Common way is: var fileName = string.Format("{0}\\fileNameHere", Directory.GetCurrentDirec ...

  4. summary CSS3 New characteristics (Transition piece )

    CSS transition (transition), yes  CSS3  Part of the norm , Used to control CSS The rate at which attributes change . You can make the property change process last for a period of time , Not immediately . such as , Change the color of the element from white to black , Usually this is changed to ...

  5. zookeeper One of series —zookeeper introduction

    Zookeeper What is it? ? Zookeeper So it's called Siyi zookeeper , It's for elephants (Hadoop). The bees (Hive). Piglets (Pig) The administrator of ,Apache Hbase and Apache Solr as well as Link ...

  6. bzoj 4025: Bipartite graph

    Description There's one of them n Graph of nodes . Because God is God , So in T Some edges will appear and disappear in time . God asked whether the graph is bipartite in each period of time . Such a simple question, of course, God will do , So he wanted to test you . Problem solving report : ...

  7. Python Revisited Day 05( modular )

    Catalog 5.1 Modules and packages 5.1.1 package 5.2 Python Overview of the standard library 5.2.1 string manipulation io.StringIO class 5.2.3 Command line design 5.2.4 Mathematics and numbers 5.2.5 Time and date 5 ...

  8. [UE4] stay C++ Chinese variables and Chinese annotations are used in

    One . If you are directly in C++ Chinese variable names are used in , stay UE4 There are errors in compiling , The Chinese annotation of the method will also be in UE4 It's a mess Two . As long as h Document and cpp Save the document in Notepad as utf-8 Just code it . You can also configure VS Environmental Science : How to solve ...

  9. spark Rapid development of scala The foundation 2 Control process

    Judging structure In general and java Quite a .scala There is no ternary expression . val num = if(1>0) 1 else 0 // Equivalent to anonymous function println(num) var num2 = 0 if(1& ...

  10. leetcode 90. A subset of II JAVA

    subject : Given an array of integers that may contain duplicate elements  nums, Returns all possible subsets of the array ( Power set ). explain : The solution set cannot contain duplicate subsets . Example : Input : [1,2,2] Output : [ [2], [1], [1,2,2] ...