This is actually an anonymous function
function(arg){...}
This defines an anonymous function with the parameter arg
and when calling the function, it is after the function When writing parentheses and actual parameters, due to the priority of the operator, the function itself also needs parentheses, that is:
(function(arg){...})(param)
This is equivalent to the definition An anonymous function with arg as a parameter, and use param as a parameter to call this anonymous function
and (function($){...})(jQuery) is the same, the reason why it is only in the formal parameter $ is used to avoid conflict with other libraries, so the actual parameters are the same as jQuery
var fn = function($){....};
fn(jQuery);