Javascript notes: Improve javascript code performance through in-depth understanding of the scope chain and execution environment

Source: Internet
Author: User
In the previous article, I ended the creation of objects and finally introduced the issue of scope chain and execution environment. When I have a deeper understanding of this knowledge, I will look back at the jQuery source code to know how powerful the code written by masters is, the scope chain and execution are well applied in jQuery source code... syntaxHighlighter. all ();

 

In the previous article, I ended the creation of objects and finally introduced the issue of scope chain and execution environment. When I have a deeper understanding of this knowledge, I will look back at the jQuery source code to know how powerful the code written by masters is, the jQuery source code uses the scope chain and execution environment knowledge to improve program performance.

Okay, no nonsense. The scope mentioned in the previous blog is relatively simple. In fact, understanding the scope is the key to understanding the entire javascript language. In particular, when I wrote javascript notes, I had a hard time understanding many weird javascript usage, the reason is that the concept of scope in javascript is not really understood.

What is the scope of Javascript? The scope determines the variables that can be accessed by the function (note: the scope is the internal attribute of the function and the scope is the function that cannot be bypassed). The scope also determines the direction of the this pointer. In the previous blog, I said that a program is actually a process of constantly retrieving data, so the efficiency of data retrieval determines the performance of the program. Therefore, since the scope determines that those variables can be accessed, of course, it also determines the way to retrieve these variables, so it is critical to write an efficient javascript program to flexibly use the principle of scope.

In the previous blog, I wrote a function with the following code:

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.