The example in this article analyzes the scope of variables within the js function. Share it with everyone for your reference. The specific analysis is as follows:
Let’s look at a function example first:
Unlike PHP, if you want to call a variable in a JS function, it first searches it within the function. For example, in the example, a is equal to 6; but c cannot be found in the function body, so it will look up outside the function body. If it finds it, it will be called. If it cannot find it, it will report an error.
I hope this article will be helpful to everyone’s JavaScript programming design.