For loop

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Case 1
const arr = [0,1,2,3,4,5];
const copyArr = [];

const testFunc = function() {
	for(let i = 0; i < arr.length; i++) {
		copyArr.push(arr[i]);
	}
}

var res = testFunc();
ready
Case 2
const arr = [0,1,2,3,4,5];
const copyArr = [];

const testFunc = function() {
	for(const a of arr) {
		copyArr.push(a);
	}
}

var res = testFunc();
ready
Case 3
const arr = [0,1,2,3,4,5];
const copyArr = [];

const testFunc = function() {
	arr.forEach((a) => {
		copyArr.push(a);
	});
}

var res = testFunc();
ready

Revisions

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