I noticed a difference when calling a function with empty parentheses, or without any parentheses at all. However, I am not passing any arguments to the function so I wonder
Functions in javascript are first-class citizens, and as such, can be assigned to other variables or passed around as arguments.
So, when you do
window.onload = initAll;
You are setting the onload
property of the window
object to reference the initAll
function itself.
When you do
window.onload = initAll();
You are setting the onload
property to hold the return value of initAll, since it will execute in place on that line.