Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash Find tests
(version: 2)
Comparing performance of:
Find - Function vs Find - _.matches shorthand vs Find - _.matchesProperty shorthand vs Find - _.property shorthand vs Vanilla Filter
Created:
7 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>
Tests:
Find - Function
let arr = [{"a":0,"b":2,"c":3},{"a":0,"b":2,"c":3},{"a":0,"b":2,"c":true}] let found = _.find(arr, (o) => { return o.c == true })
Find - _.matches shorthand
let arr = [{"a":0,"b":2,"c":3},{"a":0,"b":2,"c":3},{"a":0,"b":2,"c":true}] let found = _.find(arr, {'c': true })
Find - _.matchesProperty shorthand
let arr = [{"a":0,"b":2,"c":3},{"a":0,"b":2,"c":3},{"a":0,"b":2,"c":true}] let found = _.find(arr, ['c', true])
Find - _.property shorthand
let arr = [{"a":0,"b":2,"c":3},{"a":0,"b":2,"c":3},{"a":0,"b":2,"c":true}] let found = _.find(arr, 'c')
Vanilla Filter
let arr = [{"a":0,"b":2,"c":3},{"a":0,"b":2,"c":3},{"a":0,"b":2,"c":true}] let found = arr.filter(o => o.c == true);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (5)
Previous results
Fork
Test case name
Result
Find - Function
Find - _.matches shorthand
Find - _.matchesProperty shorthand
Find - _.property shorthand
Vanilla Filter
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 what's being tested in this benchmark. **Benchmark Overview** The benchmark is comparing the performance of four different approaches to find an element in an array: 1. Vanilla Filter 2. Lodash `find` function 3. Lodash `_` (shorthand) `find` function 4. Lodash `_` (shorthand) `matchesProperty` shorthand **Vanilla Filter** This approach uses the built-in `filter()` method to find an element in the array that matches a given condition. Pros: * Easy to understand and implement * No external dependencies required Cons: * May be slower than other approaches due to the overhead of the `filter()` method * Requires iterating over the entire array, which can be inefficient for large arrays **Lodash `find` Function** This approach uses Lodash's `find` function to find an element in the array that matches a given condition. Pros: * Well-optimized and implemented by a reputable library (Lodash) * Can take advantage of lazy evaluation to improve performance * Easy to read and understand Cons: * Requires including an external dependency (Lodash) **Lodash `_` (shorthand) `find` Function** This approach uses Lodash's `_` shorthand syntax to find an element in the array that matches a given condition. Pros: * More concise and readable than the traditional `find` function * Still leverages the optimizations of the Lodash implementation Cons: * Requires including an external dependency (Lodash) **Lodash `_` (shorthand) `matchesProperty` Shorthand** This approach uses Lodash's `_` shorthand syntax with `matchesProperty` to find an element in the array that matches a given property. Pros: * Very concise and readable * Can take advantage of lazy evaluation to improve performance Cons: * Requires including an external dependency (Lodash) **Library: Lodash** Lodash is a popular JavaScript utility library that provides a collection of helper functions for common tasks, such as array manipulation, string manipulation, and object manipulation. In this benchmark, Lodash is used to provide the `find` function and other utilities. **Special JS Feature/Syntax: None** There are no special JavaScript features or syntax used in these benchmarks. They all use standard JavaScript syntax and conventions. **Alternatives** If you're interested in exploring alternative approaches, here are a few options: * Using built-in JavaScript methods like `some()` or `every()` * Implementing your own custom filtering function * Using a different utility library (e.g., Ramda)
Related benchmarks:
Includes Test
isEmpty vs. vanilla
empty arr
isUndefined
Lodash some vs isEmpty 2
Comments
Confirm delete:
Do you really want to delete benchmark?