Setters / Getters

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
Setter / Getter
class A {
  prop = 0;
}

class B {
  _prop = 0;
  
  set prop(value) {
    this._prop = value;
  }
  
  get prop() {
    return this._prop;
  }
}

const instance = new A();
instance.prop = 4;

const i = instance.prop;
ready
Direct
class A {
  prop = 0;
}

class B {
  _prop = 0;
  
  set prop(value) {
    this._prop = value;
  }
  
  get prop() {
    return this._prop;
  }
}

const instance = new B();
instance.prop = 4;

const i = instance.prop;
ready

Revisions

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