Dollar sign before self declaring anonymous function in JavaScript?

前端 未结 5 1527
闹比i
闹比i 2020-11-29 03:08

What is the difference between these two:

$(function () {
    // do stuff
});

AND

(function () {
    // do stuff
})();
         


        
5条回答
  •  无人及你
    2020-11-29 03:41

    The first uses jQuery to bind a function to the document.ready event. The second declares and immediately executes a function.

提交回复
热议问题