JS Closed Package

Source: Internet
Author: User

Closure of four concepts, execution environment, activity object, scope, scope chain

When a function is defined, the scope of the function is determined, the entire function body is the execution environment, if the function is a global function, then its scope chain as long as the Window object, when the function is called, an active object is created, the arguments property is added to the active object, When a child function (nested function) accesses a variable, it is searched from its own active object, no more active object of the parent function is found, and then the Window object is not returned undefined.

Closure of the application scenario, 1, in memory to save a variable, when a function has sub-function (created closure), the function of the value of the variable will not start again, but the last operation after the value of the save.

2. JS private Property and private method (cannot be accessed externally) through the security of the protection variable

JS Closed Package

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.