Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36
Chrome 108
Windows
Desktop
2 years ago
Test name Executions per second
Object access 6724176.0 Ops/sec
Proxy access 5248249.0 Ops/sec
Proxy with get handler access 2383119.0 Ops/sec
Use of simple getter 5467925.0 Ops/sec
Use of defineProperty 5107767.0 Ops/sec
Script Preparation code:
AخA
 
object = { value: 'data', getData() {return this.value;} };
Object.defineProperty(object, 'dataProperty', {
  get() { return this.value; }
});
proxy = new Proxy(object, {})
proxyWithHandler = new Proxy(object, {
    get(target, prop, receiver) {
        return Reflect.get(target, prop, receiver)
    }
})
Tests:
  • Object access

     
    object.value;
  • Proxy access

     
    proxy.value
  • Proxy with get handler access

     
    proxyWithHandler.value
  • Use of simple getter

     
    object.getData();
  • Use of defineProperty

     
    object.dataProperty;