new Array() vs [] for known length

Benchmark publishedon

Setup

const totalRuns = 10000;

Test Runner

Initializing...

Testing in
Test CaseOps/sec
Using []
const x = [];
	x[0] = 0;
	x[1] = 0;
	x[2] = 0;
	x[3] = 0;
	x[4] = 0;
	x[5] = 0;
	x[6] = 0;
ready
Using new Array(7)
const x = new Array(7);
	x[0] = 0;
	x[1] = 0;
	x[2] = 0;
	x[3] = 0;
	x[4] = 0;
	x[5] = 0;
	x[6] = 0;
ready

Revisions

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

Revision 1
publishedon