Whenever I go to work with jQuery I simply create:
$(function() {
});
Because it was the first form I learned, at first I thought it was an "int main ()" pattern in C, but then I came across other shapes like:
$( document ).ready(function() {
});
$(function() {
});
$j(function() {
});
function funcao(jQuery) {
}
$( document ).ready(funcao);
What's the right way to use it? Or when is the right time to use it? Why does not pure JavaScript need? What is your role?