HTML Preparation code:
AخA
 
1
<script src="https://cdn.jsdelivr.net/lodash/4.16.0/lodash.min.js"></script>
Script Preparation code:
 
var person = {data: {type: 'Frederick'}};
Tests:
  • Lodash get string

     
    _.get(person, 'data.type');
  • Lodash get array

     
    const type = _.get(person, ['data', 'type']);
  • Native

     
    const type = person.data.type
  • Native with checking for missing object

     
    const data = person.data
    if(data !== null){
      const type = data.type
    }
  • ?.

     
    const type = person.data?.type
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Lodash get string
    Lodash get array
    Native
    Native with checking for missing object
    ?.

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:96.0) Gecko/20100101 Firefox/96.0
Firefox 96 on Ubuntu
View result in a separate tab
Test name Executions per second
Lodash get string 2929418.2 Ops/sec
Lodash get array 12417788.0 Ops/sec
Native 865745856.0 Ops/sec
Native with checking for missing object 484177152.0 Ops/sec
?. 401172160.0 Ops/sec