Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
lodash-reject-vs-vanilla-filter
(version: 0)
Benchmark.js
Comparing performance of:
reject vs filter
Created:
3 years ago
by:
Guest
Go 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:
reject
const foo = ['field1', 'field2', 'field3', 'field4', 'field5']; _.reject(foo, nextField => nextField === 'field4');
filter
const foo = ['field1', 'field2', 'field3', 'field4', 'field5']; foo.filter(i => i === 'field4')
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
reject
filter
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
9 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.0.0 Safari/537.36
Browser/OS:
Chrome 141 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
filter
31.0M/s
reject
11.4M/s
View exact numbers
Test name
Executions per second
✓
filter
30,986,798 Ops/sec
reject
11,375,871 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's dive into the world of JavaScript microbenchmarks on MeasureThat.net. **Benchmark Overview** The provided benchmark measures the performance difference between two approaches: rejecting an element in a JavaScript array using `lodash`'s `_reject()` function and filtering out an element from the same array using vanilla JavaScript's `filter()` method. **Options Compared** Two options are compared: 1. **_reject() (Lodash)**: This function is part of the popular Lodash library, which provides a collection of reusable functions for various tasks, including array manipulation. 2. **Filter () (Vanilla JavaScript)**: This is the native `filter()` method in JavaScript arrays. **Pros and Cons** **_reject() (Lodash)** Pros: * Efficient implementation for rejecting elements * Built-in support for handling different types of values * Part of a comprehensive library, making it easier to use other Lodash functions together Cons: * Requires an additional library download (lodash.js) * May have overhead due to the need to import and initialize the library **Filter () (Vanilla JavaScript)** Pros: * No additional libraries required * Native implementation, ensuring optimal performance * Easy to understand and implement Cons: * Can be slower for large arrays or complex filtering conditions * Requires explicit implementation of the filtering logic **Library: Lodash** Lodash is a popular JavaScript library that provides a collection of reusable functions for various tasks. `_reject()` is one of these functions, which allows you to reject elements from an array based on a provided condition. **Special JS Feature/ Syntax: None** This benchmark does not use any special JavaScript features or syntax beyond the standard `filter()` and `_reject()` methods. **Other Alternatives** If you want to explore other alternatives for rejecting elements in an array, consider using: 1. `Array.prototype.filter()`: The native `filter()` method is a good alternative to Lodash's `_reject()`. 2. `Array.prototype.every()`: Although not directly related to rejection, `every()` can be used with a negative condition to filter out unwanted elements. 3. `Some()` and `Every()` functions from the `Array.prototype` methods or libraries like Ramda. In conclusion, this benchmark provides a useful comparison between two approaches: Lodash's `_reject()` function and vanilla JavaScript's `filter()` method. The choice between these options depends on your specific requirements, performance considerations, and personal preference.
Related benchmarks
lodash.filter vs js native
Lodash.filter vs Lodash.without
Lodash filter VS native filter (with Lodash actually loaded)
Comments
Confirm delete:
Do you really want to delete benchmark?