Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
native find vs lodash _.find..
(version: 0)
Compare the new ES6 spread operator with the traditional concat() method
Comparing performance of:
array find vs _.find
Created:
5 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.11/lodash.core.js"></script>
Script Preparation code:
var users = [ 1, 2, 3 ]
Tests:
array find
// Native users.find(function (o) { return o == 3; })
_.find
_.find(users, function (o) { return o==3; })
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
array find
_.find
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
6 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36 Edg/141.0.0.0
Browser/OS:
Chrome 141 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
array find
119968224.0 Ops/sec
_.find
61168268.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'll break down the benchmark and explain what's being tested, compared, and considered. **Benchmark Overview** The benchmark is designed to compare two approaches for finding an element in an array: 1. Native JavaScript (using `Array.prototype.find()` method) 2. Using Lodash library (`_.find()` method) The benchmark aims to determine which approach is faster and more efficient. **Options Compared** Two options are compared: 1. **Native JavaScript**: Uses the built-in `Array.prototype.find()` method, which is a part of the ECMAScript standard. 2. **Lodash `.find()` method**: Uses the Lodash library's implementation of the `_.find()` function. **Pros and Cons of Each Approach** * **Native JavaScript (Array.prototype.find())** + Pros: - Built-in method, no additional library dependencies required - Typically faster since it's implemented in native code - Simplifies code by using a standard method for array traversal + Cons: - May have performance issues if not properly optimized or used incorrectly * **Lodash `.find()` method** + Pros: - Lodash is a widely-used and well-maintained library with extensive documentation - Can be useful when working with complex data structures or algorithms that require more functionality than `Array.prototype.find()` + Cons: - Adds an additional dependency to the project, which may increase bundle size or dependencies management complexity **Library Used (Lodash)** The Lodash library is a popular JavaScript utility library that provides a wide range of functions for various tasks, such as: * Array manipulation and filtering * String manipulation and formatting * Object manipulation and merging * Functional programming utilities In this benchmark, the `_.find()` function is used to find an element in the `users` array. **Special JS Feature/Syntax** None mentioned in this benchmark. The code uses standard JavaScript syntax and features, including ES6 spread operator (`var users = [...];`) and the `==` operator for comparison. **Other Alternatives** Alternative approaches to finding an element in an array include: * Using a traditional loop with `for` or `forEach` statements * Using other libraries like Ramda or Underscore.js (other popular utility libraries) * Implementing your own custom function using recursion or iteration However, the Lodash `.find()` method and native JavaScript's `Array.prototype.find()` method are two of the most common and efficient approaches for finding an element in an array.
Related benchmarks:
native find vs lodash _.find
native find vs lodash _.find_fork
Compare prototype.find vs lodash/find
native find vs for..in
Comments
Confirm delete:
Do you really want to delete benchmark?