[Liu Yang Java]_ Step-by-step spy JS variable scope

Source: Internet
Author: User
Tags variable scope

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.