jQuery; function of $ the use of the semicolon before undefined

  • 2020-05-07 19:11:49
  • OfStack

;(function($){$.extend($.fn...

1 usually has a semicolon in front of some JQuery functions, which can be used for a variety of purposes:

1. Prevent syntax errors in high compression after multiple files are integrated into one file.

2, this is an anonymous function, 1 js library all use this kind of self-executing anonymous function to protect the internal variables (function(){})().

3. Because undefined is an attribute of window, after declaring it as a local variable, if there is another variable in the function to compare with undefined, the program can not search undefined to window, which can improve the performance of the program.


Related articles: