Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash (omitBy & isUndefined) vs native
(version: 2)
Comparing performance of:
Lodash with _.omitBy & _.isUndefined vs Native
Created:
4 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.4/lodash.min.js"></script>
Script Preparation code:
var sampleObject = { e1: 'hello world', e2: undefined, }
Tests:
Lodash with _.omitBy & _.isUndefined
_.omitBy(sampleObject, _.isUndefined)
Native
for (const [key, value] of Object.entries(sampleObject)) { if (typeof value === 'undefined') { delete sampleObject[key] } }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Lodash with _.omitBy & _.isUndefined
Native
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36
Browser/OS:
Chrome 136 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Lodash with _.omitBy & _.isUndefined
2484438.8 Ops/sec
Native
3395759.5 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the benchmark and analyze what's being tested. **Benchmark Definition** The benchmark is designed to compare the performance of two approaches: 1. Using the Lodash library, specifically the `_.omitBy` function with the `_.isUndefined` predicate. 2. The native JavaScript implementation without any libraries. **Options Compared** In this benchmark, we have two options being compared: * Option 1: Lodash's `_.omitBy` function, which takes an object and a predicate function as arguments. It returns a new object with the values that do not match the predicate. * Option 2: A native JavaScript implementation using a simple `for...of` loop to iterate over the object entries, and then deleting any property with a value of `undefined`. **Pros and Cons** Here are some pros and cons for each option: **Lodash's `_omitBy` function:** Pros: * Concise and expressive code * Built-in support for predicate functions Cons: * Requires an additional library (Lodash) * May incur overhead due to the library's existence **Native JavaScript implementation:** Pros: * No additional library is required * Can be optimized by the interpreter or compiler Cons: * More verbose and less expressive code * Does not include built-in support for predicate functions **Library Used** In this benchmark, Lodash is used as a library to provide the `_.omitBy` function. The purpose of using a library like Lodash is to make the code more concise and readable, while also providing a standardized way to perform common operations. **Special JS Feature or Syntax** There are no special JavaScript features or syntax being used in this benchmark that would require any advanced knowledge. **Alternative Approaches** Other alternatives for implementing the `_.omitBy` function could include: * Using a custom implementation with a simple loop and conditional statements * Utilizing other libraries or frameworks that provide similar functionality (e.g., Ramda, Underscore.js) * Leveraging built-in array methods, such as `filter()` or `map()`, to achieve the desired result However, in this benchmark, Lodash's `_omitBy` function is used due to its concise and expressive nature, making it an ideal choice for performance comparison.
Related benchmarks:
Native Undefined vs Lodash isUndefined
Lodash.js vs Native - empty
Comparing performance of native .length and Lodash _.isEmpty v2
Lodash isEmpty vs Native Javascript
lodash.isUndefined vs native check is undefined
Comments
Confirm delete:
Do you really want to delete benchmark?