SeeJqueryThe first and last linesCode
(Function(Window, undefined) {}) (window );
This anonymous structure is not uncommon. What we are talking about today is not this,Second Parameter,JqueryHe has not passed the value. Why?We know that parameters without passing values will be setWindow. undefinedWhy?JqueryNot used by developersWindow. undefinedInstead of using a form parameter?
Think about it. There are at least two points worth doing this (please add ):
- undefined is set as a local variable. Local variables can be used directly in the current scope. You do not need to search for the upper-level scope chain to reduce the number of searches and improve the efficiency.
- check the compressed code. (function (a, B) {}) (window) , undefined is cleverly replaced with B , in the subsequent Code, many judgments use undefined . B . Local variables are replaced by short characters during compression, which effectively reduces the size of the compressed file, therefore, many local variables are pulled out and set, not only for temporary storage results, but also for compression.
Code there are a lot of exquisite ideas that are worth learning. They all use language skills, thoughts are important.