Home  >  Article  >  Web Front-end  >  (function($){...})(jQuery) means_jquery

(function($){...})(jQuery) means_jquery

WBOY
WBOYOriginal
2016-05-16 18:22:461012browse

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);

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn