Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash.get string vs array vs native vs ?. at depth 2
(version: 0)
Comparing performance of:
Lodash get string vs Lodash get array vs Native vs Native with checking for missing object vs ?.
Created:
4 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<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>
Run tests (5)
Previous results
Fork
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:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the provided benchmark and explain what's being tested. **Benchmark Overview** The benchmark compares the performance of four different approaches to access nested properties in JavaScript: 1. Lodash `_.get` with string indexing 2. Lodash `_.get` with array indexing 3. Native JavaScript property access 4. Native JavaScript property access with a null check for missing objects **Lodash `.get`** Lodash is a popular JavaScript utility library that provides various functions to simplify common programming tasks. * `_.get` is a function that allows you to access nested properties in an object using either string or array indexing. + String indexing uses the dot notation (e.g., `person.data.type`). + Array indexing uses the bracket notation with arrays as keys (e.g., `const type = _.get(person, ['data', 'type'])`).
Related benchmarks:
Comparing performance of: Lodash get vs Native with object checking
lodash._get vs Property dot notation
Lodash.get using string vs array at depth 2
Lodash.get string vs array vs native at depth 2
Comments
Confirm delete:
Do you really want to delete benchmark?