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: