Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash.get vs Lodash.property vs native
(version: 0)
Comparing performance of:
Lodash get vs _property vs native
Created:
7 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', foo: { bar: "baz" } }; var p = _.property("foo.bar");
Tests:
Lodash get
_.get(person, 'foo.bar');
_property
p(person);
native
person.foo.bar;
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Lodash get
_property
native
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
10 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
Browser/OS:
Chrome 137 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Lodash get
17459474.0 Ops/sec
_property
17582276.0 Ops/sec
native
223928000.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
**Overview** The provided JSON represents a JavaScript microbenchmark on MeasureThat.net, comparing the performance of `_.get()` from Lodash, `_.property()` from Lodash, and native property access in JavaScript. **Tested Options** There are three options being compared: 1. **`.get()` from Lodash**: This function is used to access nested properties of an object using a string key. 2. **`.property()` from Lodash**: This function is similar to `.get()`, but it returns the property as a function, allowing for chaining method calls. 3. **Native Property Access**: This option uses native JavaScript syntax to access the nested property `foo.bar` directly on the object. **Pros and Cons of Each Approach** 1. **`.get()` from Lodash**: * Pros: Can handle complex key paths, supports function as a callback, and is part of the popular Lodash library. * Cons: Requires an additional dependency (Lodash), can be slower due to string manipulation, and may not be optimized for performance. 2. **`.property()` from Lodash**: * Pros: Returns the property as a function, allowing for chaining method calls, and is part of the popular Lodash library. * Cons: Requires an additional dependency (Lodash), can be slower due to string manipulation, and may not be optimized for performance compared to native access. 3. **Native Property Access**: * Pros: Fastest option, no dependencies required, and optimized for performance. * Cons: May require more code to achieve the same result as Lodash functions, and may not support complex key paths. **Library and Purpose** Lodash is a popular JavaScript utility library that provides a wide range of functions for tasks such as array manipulation, object traversal, and functional programming. In this benchmark, Lodash's `_.get()` and `.property()` functions are used to access nested properties of an object. **Special JS Feature or Syntax** There doesn't appear to be any special JavaScript features or syntax being used in this benchmark beyond the standard ECMAScript syntax for accessing properties. **Other Alternatives** If you want to explore other alternatives, here are a few options: * **Underscore.js**: Another popular utility library that provides similar functions to Lodash. * **Ramda**: A functional programming library that provides a different set of functions for working with data. * **Built-in JavaScript methods**: For simple property access, built-in methods like `in` or `hasOwnProperty` can be used. However, these may not support complex key paths. **Benchmark Result Interpretation** The benchmark results show the number of executions per second (ExecutionsPerSecond) for each option on a specific device and browser configuration. The fastest option is native property access, followed by `.property()` from Lodash, and then `.get()` from Lodash.
Related benchmarks:
Lodash.get vs Property dot notation
Lodash.get vs Lodash.property vs native 2
Lodash.get vs Lodash.property vs native 3
Lodash.get vs Lodash.property vs native vs native with optional chaining
Comments
Confirm delete:
Do you really want to delete benchmark?