Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
> _.includes() vs [].includes() <
(version: 0)
Lodash vs ES6 비교
Comparing performance of:
_.includes() Test vs [].includes() Test
Created:
2 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.21/lodash.min.js"></script>
Script Preparation code:
var testArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 15, 52, 234, 123, 6349, 23234, 45930];
Tests:
_.includes() Test
_.includes(testArray, 15)
[].includes() Test
testArray.includes(15)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
_.includes() Test
[].includes() Test
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 break down the provided JSON and explain what is being tested. **Benchmark Definition** The benchmark compares the performance of two approaches: using Lodash's `_.includes()` function versus the built-in `[]` array method `.includes()`. The test case checks which approach is faster for finding an element in a large array (`testArray`). **Options Compared** 1. **Lodash's _.includes()**: This function is part of the Lodash library, which provides utility functions for various tasks, including string and array manipulation. 2. **Built-in [] array method .includes()**: This is a native JavaScript method that checks if an element exists in an array. **Pros and Cons** * **Lodash's _.includes():** + Pros: - Easy to use and more readable for complex cases - Can handle different data types (e.g., strings, numbers, objects) - Often used in larger projects with existing Lodash dependencies + Cons: - Adds extra overhead due to the need to include the entire Lodash library - Might be slower than native array methods for simple use cases * **Built-in [] array method .includes():** + Pros: - Faster and more efficient for simple array operations - Built-in, so no additional dependencies or overhead + Cons: - Can be less readable for complex cases - Not as flexible as Lodash's _.includes() in terms of data types **Library** Lodash is a popular JavaScript library that provides utility functions for various tasks. In this case, the `_.includes()` function is used to check if an element exists in an array. **Special JS Feature/Syntax** None mentioned in the provided code. Both methods use standard JavaScript syntax and don't require any special features or syntax. **Other Considerations** When choosing between these approaches, consider the trade-off between ease of use and performance. If you're working with simple arrays and need a fast solution, using the built-in `[]` array method `.includes()` might be a better choice. However, if you need more flexibility and readability for complex cases, Lodash's `_.includes()` function might be a better option. **Other Alternatives** If you want to compare other approaches, you can consider adding additional test cases, such as: * Using a custom implementation of the `includes()` method * Comparing performance with other libraries or frameworks that provide similar functionality (e.g., React's `ReactElement.includes()`) * Testing different array sizes and data types to see how the performance difference varies
Related benchmarks:
lodash vs es6 in includes method
Lodash some vs includes
Array.indexOf vs Array.includes vs lodash includes with numerical values
IndexOf vs Includes vs _.includes for number array
Comments
Confirm delete:
Do you really want to delete benchmark?