Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash.set VS property assign
(version: 0)
Compares different approaches to set an object property
Comparing performance of:
Dot notation property setter vs Lodash.set
Created:
2 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' };
Tests:
Dot notation property setter
person.age = 10
Lodash.set
_.set(person, '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/131.0.0.0 Safari/537.36
Browser/OS:
Chrome 131 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
126208320.0 Ops/sec
Lodash.set
24507132.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
**What is being tested?** MeasuresThat.net is testing two different approaches to set an object property: the dot notation (`person.age = 10`) and the Lodash library's `set` method (`_.set(person, 'age', 10)`). The benchmark is comparing the performance of these two approaches. **Options compared** The main options being compared are: 1. **Dot notation**: Setting an object property using the dot notation (e.g., `person.age = 10`). 2. **Lodash.set**: Using the Lodash library's `set` method to set an object property (e.g., `_.set(person, 'age', 10)`). **Pros and Cons** * **Dot notation:** + Pros: - Simple and concise syntax. - No additional library dependency required. - Cons: - May be slower due to the need for dynamic property lookup. - Less explicit and less readable in some cases. * **Lodash.set:** + Pros: - More efficient and faster due to optimized internal implementation. - Provides a clear and concise way to set properties without additional syntax changes. + Cons: - Requires an additional library dependency (Lodash). - May be overkill for simple use cases. **Library: Lodash** Lodash is a popular JavaScript utility library that provides a wide range of functional programming helpers, including string manipulation, array and object manipulation, and more. The `set` method in Lodash is used to set the value of a property on an object, allowing for a more explicit and efficient way to update properties. **Special JS feature or syntax** There are no special JavaScript features or syntaxes being tested in this benchmark. However, it's worth noting that some modern browsers (e.g., Chrome) support a newer version of the ECMAScript standard (ES6+) that includes improved support for object property setters, which might affect the performance of these benchmarks. **Other alternatives** If you're interested in exploring alternative approaches to setting object properties, consider the following: 1. **Object.assign()**: You can use `Object.assign()` method to assign new values to an existing object. 2. **Property access**: In some cases, accessing a property using bracket notation (e.g., `person['age'] = 10`) or dot notation with a function (e.g., `(function() { person.age = 10; })()`) might be faster due to the elimination of dynamic property lookup. Keep in mind that these alternatives may not provide the same level of performance as the optimized implementations used by Lodash's `set` method.
Related benchmarks:
Dot property set notation VS Lodash.set
Dot property set notation VS Lodash.set poop
property assign VS Lodash.set
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?