Difference between assigning event handler to method with and without parentheses
问题 Assuming you have the following: function doStuff() { //code } What is the the difference between the 2 statements ? window.onload = doStuff; window.onload = doStuff(); Both statements immediately called the method, but if I used the first statement, I could treat onload as a function pointer to "doStuff" and just call the method again using: onload(); Is this the only difference, and in general, is this all guaranteed behavior for event handlers ? 回答1: You're actually a bit off in your