Javascript loops performance tests

1 : Dumb standard loop

total = 0;
for(var i=0; i<a.length; i++)
{
    total+=a[i];
}

2 : Prefixed incrementation

total = 0;
for(var i=0; i<a.length; ++i)
{
    total+=a[i];
}

3 : Prefixed incrementation with buffered test variable

total = 0;
l = a.length;
for(var i=0; i<l; ++i)
{
    total+=a[i];
}

4 : Prefixed decrementation with buffered test variable

total = 0;
for(var i=a.length-1; i>=0; --i)
{
    total+=a[i];
}

5 : For in syntax

total = 0;
for(i in a)
{
    total+=i;
}

Results of tests (in order)

Wait for result
Wait for result
Wait for result
Wait for result
Wait for result

Functions used to benchmark the loops

var a = new Array(30000);
var total = 0;
for(var i=0; i<30000; ++i)
{
    a[i]=i;
}

function timeToRun(func)
{
    return Math.max(runTest(func),runTest(func),runTest(func));
}

function runTest(func)
{
    n1 = new Date();
        func();
    n2 = new Date();
    diff = n2.getTime() - n1.getTime();
    return diff;
}