In JavaScript, does it make a difference if I call a function with parentheses? -
i noticed difference when calling function empty parentheses, or without parentheses @ all. however, not passing arguments function wondered, difference between:
window.onload = initall(); and
window.onload = initall; please explain principle behind it.
window.onload = initall();
this executes initall() straight away , assigns function's return value window.onload. not want. initall() have return function make sense.
window.onload = initall;
this assigns actual function window.onload - possible because in javascript, @felix says, functions first class objects - without executing it. initall executed load event.
Comments
Post a Comment