Variable outside faster (v2)

Revision 2 of this benchmark created on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<div class=copy></div>
<div class=copy></div>

Test runner

Ready to run.

Testing in
TestOps/sec
inside
$('.copy').each( function() {
   var i = $(this).clone().removeClass('copy');
   $('body').append( i );
});
 
ready
outside
var i = null;
$('.copy').each( function() {
   i = $(this).clone().removeClass('copy');
   $('body').append( i );
});
ready
for loop
var copies = $('.copy');
var i
for( var x=copies.length; x>=0; x--)
{
   i = copies[x].clone().removeClass('copy');
   $('body').append( i );
} 
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.