Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash omit vs Native delete - Mantz
(version: 2)
Comparing performance of:
Native delete vs Lodash omit and pick vs Lodash omit
Created:
6 years ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js"></script>
Script Preparation code:
data = { abf:'asd',message:'koko' }
Tests:
Native delete
const meta = Object.assign({}, data); delete meta.message; return { message: data.message, meta }
Lodash omit and pick
return { message: _.pick(data, 'message'), meta: _.omit(data, 'message') }
Lodash omit
return { message: data.message, meta: _.omit(data, 'message') }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Native delete
Lodash omit and pick
Lodash omit
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one month ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:149.0) Gecko/20100101 Firefox/149.0
Browser/OS:
Firefox 149 on Mac OS X 10.15
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Native delete
26492514.0 Ops/sec
Lodash omit and pick
2734974.0 Ops/sec
Lodash omit
4636804.5 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the provided benchmark and explain what's being tested. **Benchmark Purpose:** The purpose of this benchmark is to compare the performance of two approaches for removing a specific property from an object: 1. **Native `delete`**: Using the built-in JavaScript method `delete` to remove the property. 2. **Lodash `.omit()`**: Using the Lodash library's `.omit()` function to remove properties from an object. **Test Cases:** There are three test cases: 1. **Native delete**: This test case uses the native `delete` keyword to remove the `message` property from the `meta` object. 2. **Lodash omit and pick**: This test case uses Lodash's `.omit()` function to remove all properties except `message` from the `data` object, and then assigns the resulting object to a new variable called `result`. The test case also calls Lodash's `.pick()` function with the `'message'` key to extract only the `message` property from the original data object. 3. **Lodash omit**: This test case uses Lodash's `.omit()` function to remove all properties except `message` from the `data` object. **Options Compared:** The benchmark compares the performance of these two approaches: * Native JavaScript `delete` * Lodash `.omit()` **Pros and Cons:** * **Native JavaScript `delete`**: + Pros: Fast, lightweight, and widely supported. + Cons: Can only remove one property at a time, can be brittle if the object's structure changes. * **Lodash `.omit()`**: + Pros: Flexible, can remove multiple properties, and handles complex objects with ease. + Cons: Adds dependency on Lodash library, may have performance overhead due to function call. **Library:** The Lodash library is used in this benchmark. Lodash provides a set of utility functions for working with JavaScript objects, arrays, and other data structures. **Special JS Feature/Syntax:** There's no special JavaScript feature or syntax being tested in this benchmark. The tests focus on the performance comparison between two approaches. **Other Alternatives:** If you're interested in alternative approaches to remove properties from an object, here are a few options: * Using `Object.keys()` and `forEach()` to iterate over the object's keys and delete each property individually. * Using a library like Lo-Dash (a variant of Lodash) or Underscore.js for more advanced object manipulation. Keep in mind that these alternatives may have different performance characteristics and trade-offs compared to using native JavaScript methods or Lodash functions.
Related benchmarks:
Lodash omit vs Native delete
Lodash omit vs Native delete vs Native destruct - Mantz
Lodash omit vs Native delete - Mav
Omit Vs Native Delete - Objects Pre-Initialized
Native delete vs Lodash omit - multiple properties
Comments
Confirm delete:
Do you really want to delete benchmark?