Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
_.includes() vs [].includes()
(version: 0)
Comparing performance of:
Native vs Lodash
Created:
6 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.4/lodash.min.js"></script>
Script Preparation code:
var validValues = ['completed', 'approved', 'succeeded']; var arrayData = ['this_succeeded', 'moreStuff', 'is_this_completed', 'just_approved', 'otherStuff', 'completedsoon', 'otherStuff', 'your_succeeded_code', 'things here', 'youre_approved', 'completed_the_homework', 'includessucceeded', 'otherStuff'];
Tests:
Native
arrayData.find((value) => validValues.includes(value));
Lodash
arrayData.find((value) => _.includes(validValues, value));
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Native
Lodash
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 dive into the world of MeasureThat.net and analyze the provided benchmark. **What is being tested?** The benchmark tests two approaches for searching an element in an array: the native JavaScript method (`_.includes()` in Lodash) and the native JavaScript array method `includes()`. The test case uses a sample array `arrayData` and a set of valid values `validValues`. **Options compared:** 1. **Native**: Using the native JavaScript method `includes()` on arrays. 2. **Lodash**: Using the `_.includes()` function from the Lodash library. **Pros and Cons:** * **Native (includes())**: + Pros: - Native code, potentially faster and more efficient. - No additional library dependencies. + Cons: - May have varying performance across different browsers and environments. - Not as intuitive or widely used as the Lodash version. * **Lodash (_.includes())**: + Pros: - More intuitive and widely used, especially in the JavaScript community. - Well-tested and optimized by the Lodash team. + Cons: - Requires an additional library dependency. - May have performance implications due to the extra layer of abstraction. **Other considerations:** * **Library usage**: The test case uses Lodash's `_.includes()` function, which is a popular utility function for performing array checks. This choice may reflect the author's familiarity with and preference for Lodash. * **Native JavaScript features**: Neither option explicitly tests native JavaScript features, such as arrow functions or destructuring. **Alternatives:** If you were to reimplement this benchmark without using MeasureThat.net, you could also consider testing other approaches, such as: 1. Using the `some()` method instead of `includes()`. 2. Implementing a custom array search function. 3. Comparing performance with different JavaScript engines (e.g., V8, SpiderMonkey). 4. Adding additional test cases with varying input sizes or data structures. Keep in mind that these alternatives might require modifications to the original benchmark and would likely add complexity to the testing process.
Related benchmarks:
_.includes vs includes()
Lodash some vs includes
IndexOf vs Includes vs lodash includes for string
_.includes vs includes() 2
Comments
Confirm delete:
Do you really want to delete benchmark?