# Declaring variables inside loops (v25)

## Description

Tests whether declaring a variable inside a loop, rather than declaring outside and just assigning values, is more performant

## Test runner

Testing in
TestOps/sec
Declare in a loop with one statement
``````for (var i = 0; i < 5000; i++) {
var x = 1, y = 2, z = {}, a = {};
}``````
Declare outside loop
``````var x, y, z, a, i;
for (i = 0; i < 5000; i++) {
x = 1;
y = 2;
z = {};
a = {};
}``````
Declare in a loop with multiple statements
``````for (var i = 0; i < 5000; i++) {
var x = 1;
var y = 2;
var z = {};
var a = {};
}``````
i outside, one statement inside
``````var i;
for (i = 0; i < 5000; i++) {
var x = 1, y = 2, z = {}, a = {};
}``````
Declare outside loop with i in
``````var x, y, z, a;
for (var i = 0; i < 5000; i++) {
x = 1;
y = 2;
z = {};
a = {};
}``````
Declare outside loop, +=1
``````var x, y, z, a, i;
for (i = 0; i < 5000; i+=1) {
x = 1;
y = 2;
z = {};
a = {};
}``````
Declare outside loop with i in, +=1
``````var x, y, z, a;
for (var i = 0; i < 5000; i+=1) {
x = 1;
y = 2;
z = {};
a = {};
}``````
Declare outside loop, <=
``````var x, y, z, a, i;
for (i = 0; i <= 4999; i++) {
x = 1;
y = 2;
z = {};
a = {};
}``````
``````var x, y, z, a;