variable vs function variable

JavaScript performance comparison

Test case created by mike

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
function returning variable
const testVariable = 'this is a test';
function testFunction(){
 return testVariable;
}


console.log('test', testFunction());
console.log('test', testFunction());
console.log('test', testFunction());
pending…
function saved as variable
const testVariable = 'this is a test';
function testFunction(){
 return testVariable;
}

var test = testFunction();


console.log('test', test);
console.log('test', test);
console.log('test', test);
pending…

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

0 Comments