$ is an argument to a function. jQuery is what is passed as this argument when the function is called.
Think of it this way:
function init($) {
Except this example creates a global init symbol, the execution of this and your IIFE are identical. Both define a function and immediately call it.
$ is an argument to a function. jQuery is what is passed as this argument. This serves to define $ as a shortcut to jQuery inside this function without affecting the global definition of $ . Sometimes there can also be a slight performance advantage, since characters defined locally (both local variables and named arguments) can be slightly faster than global characters.
The advantage of IIFE is that new global characters are not defined. In addition, it is identical when executing this code.
jfriend00 Sep 08 '12 at 16:16 2012-09-08 16:16
source share