Dollar sign before self declaring anonymous function in JavaScript?

前端 未结 5 1520
闹比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:42

    one is a jquery $(document).ready function and the other is just an anonymous function that calls itself.

提交回复
热议问题