xil3 xil3 - 18 days ago 5
Javascript Question

Dollar sign before self declaring anonymous function in JavaScript?

What is the difference between these two:

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


AND

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

Answer

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

Comments