The title of this article today is a very unexpected one. JS variable scope is necessary to understand, the interview process alone will let the interviewer burn skull. So, we still write a topic about the scope of JS variable, so that all the small partners can take this article to organize JS Basic learning. Maybe a lot of people would have a better idea of the basics than I do.
Golden Code Article I: JS does not have block-level scope (you can do it yourself or other methods), only function-level scope, function outside the variable function can be found inside the function inside the variable cannot find the outside
<!doctype html>
Gold code The first principle: Since the definition of variable A in method m02 is a local variable, it does not affect the outermost var a = 10; The value
Golden Code Article II: Define the variable var a = b = 10 in the function, in fact A is a local variable and B is a global variable . The pit of this program is really hard for programmers to accept
<!doctype html>
[Liu Yang Java]_ Step-by-step spy JS variable scope