立即触发的函数表达式

保护您的全球环境免受代码的污染,使用即时召唤函数表达式(IIFE)。

1(function() {
2  // your stuff here
3})();

变量过渡

您可以通过IIFE范围中的变量,如下:

1(function($) {
2  // $ == jQuery;
3})(jQuery);
Published At
Categories with 技术
Tagged with
comments powered by Disqus