Data array to class instance

Benchmark created on


Setup

class Color {
	r = 0;
	g = 0;
	b = 0;

	constructor(r, g, b) {
		this.r = r;
		this.g = g;
		this.b = b;
	}
}

const data = [255, 128, 0];

Test runner

Ready to run.

Testing in
TestOps/sec
Array destructuring
const [r, g, b] = data;
const color = new Color(r, g, b);
ready
Index access
const color = new Color(data[0], data[1], data[2]);
ready
Spread operator
const color = new Color(...data);
ready

Revisions

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