title: Self evaluating Javascript
body: <p>Please help me to understand this in javascript how this works fine?</p>
  
  <pre><code>var myEvent = window.attachEvent || window.addEventListener;
  var chkevent = window.attachEvent ? 'onbeforeunload' : 'beforeunload'; /// make IE7, IE8 compitable
  
      myEvent(chkevent, function(e) { // For &gt;=IE7, Chrome, Firefox
          var confirmationMessage = 'Are you sure to leave the page?';  // a space
          (e || window.event).returnValue = confirmationMessage;
          return confirmationMessage;
      });
  </code></pre>
  
  <p>I understand the other parts of the script but not the <code>(e || window.event).returnValue</code> how thus it will be evaluated? does it means if <code>e</code> is true then its property <code>returnValue</code> will be set else it will use the <code>window.event</code>?</p>
  
  <p>NOTE: Please guide me with the right title for this question as I don't know how this kind of javascript coding pattern is called</p>