Iโm going to suggest that you know what a field of computer science is. If not, read the wiki page.
In javascript, every function has a scope. In addition, there is a global scope (when a variable is defined outside of any function in the global scope or in a function if var not specified in the definition). Areas of hierarchy. If you have a function F and a function G inside F, when you try to access a variable in G, it checks to see if the variable is defined in area G. If not, it will try to use the F-area. If not, he will try in a global area.
All 3 variables are different (because they were defined with var ), and you can change them in a global scope, in F or in G.
All 3 variables are actually one, available anywhere (because it is in a global scope). Change will affect all 3 areas.
Since a was defined in G , inside it it is distinct and isolated from the outside. Meaning, nothing outside G can access or change the variable a , which is inside. They will only see a (if defined) from the global area. Also, due to the behavior of the function region, the function G exists only inside F ; you cannot call it from the outside.
Look at the areas like containers. They can be nested. You cannot look inside, but they may look outside.
source share