Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Dot property set notation VS Lodash.set (Nested)
(version: 0)
Compares different approaches to set an object property
Comparing performance of:
Dot notation property setter vs Lodash.set
Created:
5 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.5/lodash.min.js"></script>
Script Preparation code:
var person = { name: 'Foo', lastName: 'Bar', a:{ b: {} } };
Tests:
Dot notation property setter
_.set(person, 'a.b.age', 10)
Lodash.set
person.a.b.age = 10
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Dot notation property setter
Lodash.set
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36
Browser/OS:
Chrome 135 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Dot notation property setter
8107851.5 Ops/sec
Lodash.set
167808288.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the benchmark and its test cases. **Benchmark Definition JSON** The provided JSON represents a JavaScript microbenchmark created on MeasureThat.net. The benchmark is named "Dot property set notation VS Lodash.set (Nested)". **What is tested?** The benchmark tests two approaches to set an object property: 1. **Dot notation**: This approach uses the dot notation (`.`) to access nested properties of an object. 2. **Lodash.set**: This approach uses the `_.set()` function from the Lodash library to set a property value. **Options compared** The benchmark compares two options: * Dot notation (property chaining) * Lodash.set Both approaches have their own pros and cons: * **Dot notation**: + Pros: Simple, readable, and efficient for simple cases. + Cons: Can be cumbersome when dealing with deeply nested objects or large number of properties. * **Lodash.set**: + Pros: Convenient, flexible, and well-documented, especially for larger projects. + Cons: Adds an external dependency (Lodash), which may not be desirable in all cases. **Library used** The benchmark uses Lodash version 4.17.5. **Special JS feature or syntax** There is no specific JavaScript feature or syntax being tested in this benchmark. The focus is on comparing two different approaches to set an object property. **Benchmark preparation code and individual test cases** The preparation code defines a sample `person` object with nested properties: ```javascript var person = { name: 'Foo', lastName: 'Bar', a:{ b: {} } }; ``` Individual test cases define the benchmark definitions for each approach: 1. **Dot notation property setter**: ```javascript _.set(person, 'a.b.age', 10); ``` 2. **Lodash.set**: ```javascript person.a.b.age = 10; ``` These test cases are likely used to measure the performance difference between the two approaches. **Latest benchmark result** The latest result shows that Lodash.set outperforms dot notation property setter in this specific benchmark, with a higher number of executions per second on Firefox 91 running on Linux. However, without more context or comparisons to other browsers, operating systems, and architectures, it's difficult to draw definitive conclusions about the performance characteristics of these two approaches. **Other alternatives** If you're looking for alternative approaches to set object properties, some other options might include: * Using a library like Underscore.js (similar to Lodash) * Implementing a custom setter function or method * Using ES6's optional chaining (`?.`) with a more complex data structure However, the choice of approach often depends on the specific requirements and constraints of your project.
Related benchmarks:
Dot property set notation VS Lodash.set
Dot property set notation VS Lodash.set poop
Dot property set notation VS Lodash.set (fix)
Dot property set notation VS Lodash.set (initial attribute existing 2)
Comments
Confirm delete:
Do you really want to delete benchmark?