Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash.get vs Property dot notation
(version: 0)
Comparing performance of:
Lodash get vs Native
Created:
8 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 = {name: 'Frederick', lastName: 'Corcino Alejo'};
Tests:
Lodash get
_.get(person, 'name');
Native
person.name
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Lodash get
Native
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Safari/605.1.15
Browser/OS:
Safari 18 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Lodash get
81500760.0 Ops/sec
Native
841988288.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the provided JSON benchmark definition and test cases to understand what's being tested. **Benchmark Definition:** The benchmark measures the performance difference between two approaches: 1. `_.get(person, 'name');` using Lodash 2. `person.name` These two approaches are used to access a property (`"name"` in this case) of an object (`person`). **Options Compared:** The options being compared are: * Using Lodash's `_.get()` method with two arguments (the object and the path to the desired property) * Directly accessing the property using dot notation (`person.name`) **Pros and Cons of Each Approach:** 1. **Lodash's `_.get()` method:** * Pros: + Can handle nested properties and is more flexible than direct dot notation. + Reduces the risk of typos or incorrect property names. * Cons: + Requires an external library (Lodash) to be loaded, which may add overhead. + May introduce additional processing time due to the extra function call. 2. **Direct Dot Notation (`person.name`):** * Pros: + Faster and more lightweight than using `_.get()`, as it only involves a simple property access. * Cons: + Less flexible, as it's limited to accessing properties directly on an object. **Other Considerations:** * The benchmark is run in a browser environment (Chrome 128) with a Windows desktop device. This may affect the results due to differences in rendering engines or hardware capabilities. * The test uses Lodash version 4.16.0, which may impact performance due to optimizations or changes made since then. **Library:** In this benchmark, Lodash is used as a utility library for accessing nested properties with the `_.get()` method. This allows for more flexibility and reduces the risk of typos, making it easier to write maintainable code. No special JavaScript features or syntax are used in these test cases. **Alternatives:** If you prefer not to use Lodash, other alternatives for accessing nested properties include: * Using a library like `lodash-es` (ES version) which is optimized for ES module systems * Implementing your own utility function for accessing nested properties * Using a different JavaScript library or framework that provides similar functionality, such as React's `useCallback` and `useMemo` Keep in mind that the best approach will depend on your specific use case, performance requirements, and personal preferences.
Related benchmarks:
Lodash.get vs Property dot notation with sanity check
Lodash.get vs Property dot notation for defaults
Lodash.get vs Property dot notation @movlan
Lodash.get vs Property dot notation with ?
Comments
Confirm delete:
Do you really want to delete benchmark?