Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/110.0
Firefox 110
Windows
Desktop
one year ago
Test name Executions per second
Read directly from prop 1533605504.0 Ops/sec
Set directly to prop 1072833792.0 Ops/sec
Read from getter 1526609792.0 Ops/sec
Set to setter 1037035584.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;