Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
lodash vs es6 in includes method
(version: 0)
Comparing performance of:
lodash includes method vs es6 includes method
Created:
6 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 array = ['a', 'b', 'c', 'd', 'e', 'f', 'g'];
Tests:
lodash includes method
var result = _.includes(array, 'd');
es6 includes method
var result = array.includes('d');
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
lodash includes method
es6 includes method
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
2 years ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Browser/OS:
Chrome 121 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
lodash includes method
8203975.5 Ops/sec
es6 includes method
30497984.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's dive into the world of JavaScript microbenchmarks. **Benchmark Overview** The provided benchmark compares the performance of two approaches for checking if an element is included in an array: the `includes` method (introduced in ECMAScript 2015) and the Lodash library's `includes` function. **Options Compared** Two options are compared: 1. **ES6 includes method**: This method uses the `includes` keyword to check if a value is present in an array. 2. **Lodash includes function**: This function is part of the popular Lodash library, which provides various utility functions for JavaScript. **Pros and Cons** ### ES6 includes method Pros: * Native implementation: The `includes` method is a built-in function in modern JavaScript engines, making it efficient and well-optimized. * Simple and concise syntax: The `includes` keyword is easy to read and write. Cons: * Limited browser support: Although the `includes` method was introduced in ECMAScript 2015, older browsers may not support it. In this benchmark, both tests are run on Chrome 121, which supports ES6 features. * Potential performance differences: While modern JavaScript engines optimize the `includes` method, some older engines might have slower performance. ### Lodash includes function Pros: * Wide browser support: Lodash provides polyfills for older browsers, ensuring compatibility with a broader range of devices and versions. * Performance in older browsers: The Lodash implementation can outperform the native `includes` method in older browsers due to its optimization and polyfilling efforts. Cons: * Additional dependency: Using Lodash requires including an external library, which might not be desirable for smaller projects or projects with strict dependencies. * Simpler syntax: While the `includes` function is a valid method, it's not as concise as the native `includes` keyword. **Library and Purpose** In this benchmark, Lodash is used to provide its `includes` function, which takes two arguments: the array to search in and the value to search for. The purpose of this function is to check if the value is present in the array. **Special JS Feature or Syntax** None mentioned in the provided information. **Other Alternatives** If you're interested in exploring other options, here are a few alternatives: * **Native JavaScript methods**: Besides `includes`, other native JavaScript methods for working with arrays include `indexOf()`, `lastIndexOf()`, and `some()`. * **Third-party libraries**: Other popular array manipulation libraries like Array.prototype.forEach(), Array.prototype.some(), or libraries like Ramda can be used instead of Lodash. Keep in mind that the choice of implementation depends on your specific use case, project requirements, and performance considerations.
Related benchmarks:
_.includes vs includes() vs indexof
lodash vs es6 in indexOf method
Lodash some vs includes
IndexOf vs Includes vs lodash includes test2
Comments
Confirm delete:
Do you really want to delete benchmark?