Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
IndexOf vs Includes vs lodash includes vs vs lodash IndexOf
(version: 0)
Test native & lodash
Comparing performance of:
IndexOf vs Includes vs lodash vs lodash indexOf
Created:
4 years ago
by:
Guest
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 array = ['banana', 'sausage', 'jesus','TCy3Kepn1oZBGmhTsozfYSSfFxVMfAhAsp','TCy3Kepn1oZBGmhTsozfYSSfFxVMfAhAspb','TCy3Kepn1oZBGmhTsozfYSSfFxVMfAhAspc','TCy3Kepn1oZBGmhTsozfYSSfFxVMfAhAspd','TCy3Kepn1oZBGmhTsozfYSSfFxVMfAhAspe','TCy3Kepn1oZBGmhTsozfYSSfFxVMfAhAspf','TCy3Kepn1oZBGmhTsozfYSSfFxVMfAhAspg','TCy3Kepn1oZBGmhTsozfYSSfFxVMfAhAsph','TCy3Kepn1oZBGmhTsozfYSSfFxVMfAhAspi']
Tests:
IndexOf
array.indexOf('TCy3Kepn1oZBGmhTsozfYSSfFxVMfAhAsph') !== 1
Includes
array.includes('TCy3Kepn1oZBGmhTsozfYSSfFxVMfAhAsph')
lodash
_.includes(array, 'TCy3Kepn1oZBGmhTsozfYSSfFxVMfAhAsph')
lodash indexOf
_.indexOf(array, 'TCy3Kepn1oZBGmhTsozfYSSfFxVMfAhAsph') !== 1
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
IndexOf
Includes
lodash
lodash indexOf
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):
The provided JSON represents a JavaScript benchmark test on MeasureThat.net. The purpose of this benchmark is to compare the performance of different methods for searching an array: 1. `array.indexOf('TCy3Kepn1oZBGmhTsozfYSSfFxVMfAhAsph')` 2. `array.includes('TCy3Kepn1oZBGmhTsozfYSSfFxVMfAhAsph')` 3. Using the Lodash library's `_.includes(array, 'TCy3Kepn1oZBGmhTsozfYSSfFxVMfAhAsph')` method 4. Using the Lodash library's `_.indexOf(array, 'TCy3Kepn1oZBGmhTsozfYSSfFxVMfAhAsph')` method **Options Compared:** * Native JavaScript methods (`array.indexOf()` and `array.includes()`) * Lodash library's `_.includes()` method * Lodash library's `_.indexOf()` method **Pros and Cons of Different Approaches:** 1. **Native JavaScript methods (`array.indexOf()` and `array.includes()`)**: * Pros: Built-in methods, no external dependencies. * Cons: May be slower due to overhead of calling native functions. 2. **Lodash library's `_.includes()` method**: * Pros: Provides a consistent interface for including arrays, easy to use, and well-maintained. * Cons: Requires an external dependency (the Lodash library). 3. **Lodash library's `_.indexOf()` method**: * Pros: Similar to native `array.indexOf()` but with more features (e.g., handling null or undefined values). * Cons: Requires an external dependency (the Lodash library). **Other Considerations:** * The benchmark uses a fixed array of 11 elements, which may not be representative of real-world scenarios. * The tests are run on Chrome 92 on a Mac with macOS 10.15.7, which may introduce platform-specific biases. **Library:** The Lodash library is a popular JavaScript utility library that provides a wide range of functions for tasks like array manipulation, string manipulation, and more. In this benchmark, the `_.includes()` and `_.indexOf()` methods are used to provide an alternative interface to the native `array.includes()` and `array.indexOf()` methods. **Special JS Feature or Syntax:** There is no special JavaScript feature or syntax being tested in this benchmark. The focus is on comparing different methods for searching an array, which is a fundamental operation in JavaScript programming. **Alternatives:** Other alternatives to Lodash's `_.includes()` and `_.indexOf()` methods could be implemented using other libraries (e.g., underscore.js) or custom implementations using native JavaScript functions. Additionally, some developers might use their own implementation of these methods without relying on external libraries.
Related benchmarks:
IndexOf vs Includes vs lodash includes
IndexOf vs Includes vs lodash includes v3
indexOf vs includes vs some - 20211114
IndexOf vs Includes vs lodash includes on the arrays of strings
Comments
Confirm delete:
Do you really want to delete benchmark?