Object property vs reading from variable

Benchmark created on


Setup


Teardown


Test runner

Ready to run.

Testing in
TestOps/sec
Reading from array index
const obj = [{
	n: "test",
	b: "123",
	c: "bna"
},
{
	n: "test",
	b: "123",
	c: "bna"
}];

const name = obj[1].n;
const b = obj[1].b;
const c = obj[1].c;
ready
Reading from saved const
const obj = [{
	n: "test",
	b: "123",
	c: "bna"
},
{
	n: "test",
	b: "123",
	c: "bna"
}];

const newObj = obj[1];

const name = newObj.n;
const b = newObj.b;
const c = newObj.c;
ready

Revisions

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