Multiple choice technology web technology

What are the ways to assign event handlers in java script (for example, to show a message box while closing the window) ?

  1. window.onunload=function() { alert('closing'); }

  2. window.onunload+=onClose; function onClose() { alert('closing'); }

  3. window.onunload=onClose; function onClose() { alert('closing'); }

  4. All the above

Reveal answer Fill a bubble to check yourself
A,C Correct answer
Explanation

In JavaScript, you can assign an event handler by setting the event property to an anonymous function or to a named function reference. Using += on event properties is invalid syntax in standard JavaScript.