Data object to class instance (v2)

Revision 2 of this 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 = {r: 255, g: 128, b: 0};

Test runner

Ready to run.

Testing in
TestOps/sec
Object destructuring
const {r, g, b} = data;
const color = new Color(r, g, b);
ready
Property access
const color = new Color(data.r, data.g, data.b);
ready

Revisions

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