Script Preparation code:
AخA
 
var obj = {a: 'name'};
var obj2 = undefined;
var complexObj = {a: {b: 'name'}}
var complexObj2 = {a: {b: undefined}};
Tests:
  • optional deez

     
    let val = obj?.a;
  • if deez

     
    let val;
    if(obj && obj.a) {
        val = obj.a
    }
  • optional nutz

     
    let val = obj2?.a;
  • if nutz

     
    let val;
    if(obj2 && obj2.a) {
        val = obj2.a
    }
  • optional sugon

     
    let val = complexObj?.a?.b;
  • if sugon

     
    let val;
    if(complexObj && complexObj.a && complexObj.a.b) {
        val = complexObj.a.b;
    }
  • optional sugondeez

     
    let val = complexObj2?.a?.b;
  • if sugondeez

     
    let val;
    if(complexObj2 && complexObj2.a && complexObj2.a.b) {
        val = complexObj2.a.b;
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    optional deez
    if deez
    optional nutz
    if nutz
    optional sugon
    if sugon
    optional sugondeez
    if sugondeez

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 2 years ago)
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36
Chrome 106 on Linux
View result in a separate tab
Test name Executions per second
optional deez 25464790.0 Ops/sec
if deez 8300625.0 Ops/sec
optional nutz 23507550.0 Ops/sec
if nutz 22775068.0 Ops/sec
optional sugon 24508204.0 Ops/sec
if sugon 6258838.0 Ops/sec
optional sugondeez 24649244.0 Ops/sec
if sugondeez 8281298.0 Ops/sec