title: With jQuery is it faster to assign a variable or use $(this) for single use?
body: <p>My question is driven by curiosity, and I appreciate any performance difference is liable to be minuscule.</p>
  
  <p>I was recently looking at producing some hover effects for an image map. As with most things someone else had suggested a method with jQuery. Below was the suggest code</p>
  
  <pre><code>$('#borders area').each(function(){
      var mapRegion = $(this).attr('class');
      $(this).hover(
          function(){
              $('#regions').addClass(mapRegion).show();
          },
          function(){
              $('#regions').hide().removeClass(mapRegion);
      });
  });
  </code></pre>
  
  <p>This obviously works fine where <code>&lt;div id="regions"&gt;</code> is positioned absolutely above a base <code>&lt;img&gt;</code> and the a further blank transparent <code>&lt;img&gt;</code> is placed above this for <code>&lt;map id="borders"&gt;</code>.</p>
  
  <p>I did wonder however if it made more sense (slightly less code) to do the following with the jQuery</p>
  
  <pre><code>$('#borders area').each(function(){
      $(this).hover(
          function(){
              $('#regions').removeClass().addClass($(this).attr('class')).show();
          },
          function(){
              $('#regions').hide();
      });
  });
  </code></pre>
  
  <p>Would this be faster as no variable is set? Does removeClass() work faster without a parameter supplied? I suppose I would also be interested to know which semantically is considered better.</p>