Shadow value in loop or no

Benchmark created on


Setup

function f0(x) {
	return x + 1;
}
function f1() {
	let x;
	
	for(let i = 0; i < 100_000; i++) {
		x = Math.random();
		f0(x);
	}
}
function f2() {
	for(let i = 0; i < 100_000; i++) {
		let x = Math.random();
		f0(x);
	}
}

Test runner

Ready to run.

Testing in
TestOps/sec
Shadow variable in loop
f1()
ready
Don't shadow variable in loop
f2()
ready

Revisions

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