I am debugging someone else's JavaScript code and a majority of the code is wrapped like this:
(function ($) {
//majority of code here...
})(jQuery);
What is going on with the ($)
and the (jQuery)
? I wasn't taught to code like that and haven't seen them. What is their purpose?
As well, there is no document.ready
, but I assume that is because the code is executed right after it's read by the ();
at the end?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…