Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
native findLastIndex vs lodash _.findLastIndex
(version: 3)
Compare lodash findLastIndex with native reverse and findIndex.
Comparing performance of:
array findLastIndex vs _.findLastIndex
Created:
2 years ago
by:
Registered User
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 src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
var users = [ { 'user': 'joey', 'age': 32 }, { 'user': 'ross', 'age': 41 }, { 'user': 'chandler', 'age': 39 } ]
Tests:
array findLastIndex
// Native users.findLastIndex(function (o) { return o.age === 41; })
_.findLastIndex
_.findLastIndex(users, function (o) { return o.age === 41; })
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
array findLastIndex
_.findLastIndex
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/605.1.15 (KHTML, like Gecko) Version/17.2.1 Safari/605.1.15
Browser/OS:
Safari 17 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
array findLastIndex
23438576.0 Ops/sec
_.findLastIndex
8558204.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's dive into the world of MeasureThat.net and analyze the provided benchmark. **Benchmark Definition** The benchmark compares two approaches: using native JavaScript ( built-in function `findLastIndex`) versus using the popular utility library Lodash (`_.findLastIndex`). The goal is to determine which approach is faster in terms of performance. **Options Compared** Two options are compared: 1. **Native findLastIndex**: This uses the built-in JavaScript function `findLastIndex` on an array. 2. **Lodash _.findLastIndex**: This uses the Lodash library's implementation of `findLastIndex`, which is a wrapper around the native JavaScript function. **Pros and Cons** **Native findLastIndex** Pros: * Faster execution time, as it doesn't require additional overhead from the Lodash library. * Smaller binary size, as it only includes the native JavaScript functions. Cons: * Limited functionality compared to Lodash's implementation, which provides additional features like handling null or undefined values. **Lodash _.findLastIndex** Pros: * More robust and feature-rich implementation, providing support for various edge cases (e.g., handling null or undefined values). * Easier to use, as it follows a consistent naming convention and syntax. Cons: * Slower execution time due to the added overhead from the Lodash library. * Larger binary size compared to the native JavaScript function. **Library: Lodash** Lodash is a popular utility library for JavaScript that provides a collection of functional programming helpers. In this benchmark, `_` is used as an alias for the `lodash` namespace. The `findLastIndex` function in Lodash wraps around the native JavaScript function and provides additional features like null or undefined value handling. **Special JS Feature/Syntax** There are no special JavaScript features or syntaxes mentioned in this benchmark. **Other Alternatives** If you're interested in exploring alternative approaches, here are a few options: * **Underscore.js**: Similar to Lodash, but with fewer dependencies and a more minimalist approach. * **Array.prototype.findLastIndex()**: Some browsers (like Chrome) have implemented the `findLastIndex()` method on the Array prototype. This would eliminate the need for either native or Lodash implementation. In summary, MeasureThat.net provides a straightforward comparison between using native JavaScript's `findLastIndex` and Lodash's `_findLastIndex`. While native is likely to be faster, Lodash offers more features and might be preferred in certain scenarios.
Related benchmarks:
lodash find vs native find by id
Array find vs lodash _.find
native find vs lodash _.find equal
native find vs lodash _.find_fork
native find vs lodash _.find for objects equality
Comments
Confirm delete:
Do you really want to delete benchmark?