Look at the following code:
window.onload = someFunction;
Many times I see the use of this kind of code and even I use the same. But, there are still few things unclear.
- The above is a call to
someFunctionas soon as the page loads, right. But, aren't we supposed to call a function with brackets()? - From my understanding, we are just assigning
someFunctiontowindow.onload, therefore can we or shouldn't we callwindow.onload(); - Are there such cases, when
functionName()andfunctionNamebecames interchangeable. Because at many places, and in various API, I have seen calling the function without brackets.