HTML Preparation code:
AخA
 
1
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
 
var obj = {a: {b: {c: {d: 1}}}}
var badObj = {}
Tests:
  • Optional Chaining

     
    obj?.a?.b?.c?.d
    badObj?.a?.b?.c?.d ?? 2
  • Lodash

     
    _.get(obj, "a.b.c.d")
    _.get(badObj, "a.b.c.d", 2)
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Optional Chaining
    Lodash

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 28 days ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:135.0) Gecko/20100101 Firefox/135.0
Firefox 135 on Mac OS X 10.15
View result in a separate tab
Test name Executions per second
Optional Chaining 254689728.0 Ops/sec
Lodash 8923687.0 Ops/sec