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
someFunction
as soon as the page loads, right. But, aren't we supposed to call a function with brackets()
? - From my understanding, we are just assigning
someFunction
towindow.onload
, therefore can we or shouldn't we callwindow.onload()
; - Are there such cases, when
functionName()
andfunctionName
becames interchangeable. Because at many places, and in various API, I have seen calling the function without brackets.