What is the classification of JavaScript local scope
JavaScript local scope of the classification is how, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
1. The variables and functions in the scope of the function can only be accessed from within the function, the scope is hierarchical, and the internal function can access the variables in the scope of the external function.
Function foo () {var localVar = 'local' function localFunc () {console.log (local)} localFunc () / / local} localFunc () / / error report
2. block-level scope, and the declared variables can only be accessed within the scope of the specified block.
ES6 adds two commands to declare variables, let and const.
Console.log (b) / / undefinedconsole.log (a) / / Uncaught ReferenceError: an is not definedlet a ='i am there'var b ='I am here', is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.