Arrow vs regular functions, anonymous vs named.

Benchmark created on


Setup

const data = new Array(10000).fill(true).map((v) => Math.random()); 

Test runner

Ready to run.

Testing in
TestOps/sec
Anonymous function
const result = data.filter(function(v) {
   return v< 0.3;
}); 
ready
Anonymous arrow
const result = data.filter((v) => v < 0.3); 
ready
Named function
function fn(v) {
    return v < 0.3; 
}

const result = data.filter(fn); 
ready
Named arrow
const fn = (v) => v <0.3; 

const result = data.filter(fn); 
ready

Revisions

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