You'll find it everywhere!

the first is a closure, it allows 'some code' to have real local variables
the second is a closure with the added benefit that $ can be used for
jQuery. It's used in plugins just to make sure $ is really jQuery's $ and
not the $ from another library.

there are lots of twists on this concept! it's very valuable for scoping
local variables. Without it a var is only local to the function that
declares it.

Hope that helps!

On 5/17/07, Shuai Yang <[EMAIL PROTECTED]> wrote:


I found Jörn Zaefferer's "jQuery plugin authoring guide" at
http://bassistance.de/2006/12/27/jquery-plugin-authoring-guide/,
there i found javascript syntax like this:
========================
(function() {
  // some code here
})();
========================
(function($) {
  // some code here
})(jQuery);
========================
it really works,but i donno what exactly this syntax means,anyone can
explain it? great thanks!




--
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ

Reply via email to