title: How to create shorter equivalent for addEventListener
body: <p>I want to create a short function for <code>addEvenTListener</code> like jQuery does. I have seperate functions for select and event listener. But I want to be able to use <code>$(selector).on</code> instead of <code>on(event, elem, callback, capture)</code>. How can I achieve that?</p>
  
  <pre><code>function $ (selector, scope) {
      scope = scope ? scope : document;
      return   scope.querySelector(selector);
  };
  
  var on = function (event, elem, callback, capture) {
  
      if (typeof (elem) === 'function') {
          capture = callback;
          callback = elem;
          elem = window;
      }
      capture = capture ? true : false;
      elem = typeof elem === 'string' ? document.querySelector(elem) : elem;
      if (!elem) return;
      elem.addEventListener(event, callback, capture);
  };
  </code></pre>