Function call vs assignment

Benchmark created on


Setup

const keyToFind = "theMagic";
const obj = {};

function assignIt(key, value) {
	obj[key] = value;
}

Test runner

Ready to run.

Testing in
TestOps/sec
Assignment
let index = Math.random() * 20000;
obj[index] = "yay!";
obj[index] = undefined;
ready
function
index = Math.random() * 20000;
assignIt(index, "yay!");
assignIt(index, undefined);
ready

Revisions

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