Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
Chrome 115
Windows
Desktop
one year ago
Test name Executions per second
Read directly from prop 18058308.0 Ops/sec
Set directly to prop 18058876.0 Ops/sec
Read from getter 18108138.0 Ops/sec
Set to setter 17917790.0 Ops/sec
Script Preparation code:
x
 
class MyObj {
    prop = undefined
    get propAccessor() {
        return this.prop;
    }
    set propAccessor(val) {
        this.prop = val;
    }
}
var obj = new MyObj();
Tests:
  • Read directly from prop

     
    var value = obj.prop;
  • Set directly to prop

     
    obj.prop = 123;
  • Read from getter

     
    var value = obj.propAccessor;
  • Set to setter

     
    obj.propAccessor = 123;