Access Public vs. Private

Benchmark created on


Description

Test differences between public and private members for read/write.

Setup

class CPrivate {
	#pri = Math.random();
	read() {
		return this.#pri;
	}
	write(val) {
		this.#pri = val;
	}
 }
const c1 = new CPrivate();

class CPublic {
	pub = Math.random();
	read() {
		return this.pub;
	}
	write(val) {
		this.pub = val;
	}
}
const c2 = new CPublic();

Test runner

Ready to run.

Testing in
TestOps/sec
Read Private
c1.read()
ready
Read Public
c2.read()
ready
Write Private
c1.write(Math.random());
ready
Write Public
c2.write(Math.random());
ready

Revisions

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