title: JavaScript .length performance
body: <p>I have a pretty mundane task, but I got to wondering how the performance of these two methods vary. I'm trying to get the total number of checked checkboxes and display that to the user:</p>
  
  <pre><code>$(document).on('change', ':checkbox', function() {
      if ( $(this).is(':checked') )
          count++;
      else
          count--;
  
      $count.html(count);
   });
  </code></pre>
  
  <p>versus</p>
  
  <pre><code> $(document).on('change', ':checkbox', function() {
      $count.html($(':checkbox:checked').length);
   });
  </code></pre>
  
  <p>Thanks!</p>