Fotiman - 5:34 pm on May 4, 2012 (gmt 0)
condition ? expr1 : expr2;
In the example above, window.addEventListener? is looking to see if addEventListener exists for the window object. If browsers have a window object that defines addEventListener, then this will evaluate to a truthy condition, whereby expr1 will be called (window.addEventListener('load',init,false)). Otherwise, expr2 will be called (window.attachEvent('onload',init)).
addEventListener is the "standards" way to add event listers, while attachEvent is IE specific (IE9 added support for addEventListener, but earlier versions used only attachEvent). In other words, if the browser support the standard addEventListeners, use it, otherwise (the browser is old IE), use attachEvent.
If you've been taught to use #3 only, you should complain to your teacher.