Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
_.includes vs includes() 2
(version: 0)
Comparing performance of:
Lodash vs Native
Created:
2 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
var data = ['mustafa', 'kemal', 'atatürk'];
Tests:
Lodash
_.includes(data, 'kemal');
Native
data.includes('kemal');
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Lodash
Native
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 benchmark and explain what's being tested, compared, and analyzed. **What is being tested?** The benchmark measures the performance difference between two approaches: `_.includes()` from the Lodash library and the native `includes()` method in JavaScript. **Options being compared** Two options are compared: 1. **Lodash's `_includes()`**: This function is part of the Lodash utility library, which provides a set of helper functions for common tasks like array manipulation, string processing, and more. 2. **Native `includes()`**: This is the built-in method in JavaScript that checks if an element is present in an array. **Pros and Cons of each approach** 1. **Lodash's `_includes()`**: * Pros: Can handle more complex scenarios like checking for presence with a specific index, or using a callback function. * Cons: Adds overhead due to the library, which may not be necessary for simple use cases. 2. **Native `includes()`**: * Pros: Lightweight and efficient, making it suitable for performance-critical applications. * Cons: May have limitations in terms of handling more complex scenarios (e.g., multiple values, arrays with non-numeric indices). **Library and its purpose** The Lodash library is a popular utility library that provides a set of functional programming helpers. In this benchmark, the `_includes()` function is used to check if an element is present in an array. **Special JS feature or syntax (not applicable)** There are no special JavaScript features or syntax mentioned in the benchmark. Both `_.includes()` and `includes()` follow standard JavaScript syntax. **Other alternatives** If you're looking for alternative approaches, here are a few options: 1. **Using `Array.prototype.some()`**: This method is similar to `includes()` but may be slower due to its more complex implementation. 2. **Using `Array.prototype.findIndex()` and `=== 0`**: This approach finds the index of the first occurrence of an element in the array, then checks if it's equal to zero (i.e., present).
Related benchmarks:
_.includes vs includes()
_.includes vs includes() vs indexof
Includes Test
Lodash@4.17.21 includes vs native includes
Comments
Confirm delete:
Do you really want to delete benchmark?