Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash omit vs Native delete vs Deconstruct - Test
(version: 0)
Comparing performance of:
Native delete vs Deconstruct vs Lodash omit
Created:
3 years ago
by:
Guest
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 }
Deconstruct
const { message, ...rest } = data; return { message: data.message, meta: rest }
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
Deconstruct
Lodash omit
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/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Browser/OS:
Chrome 120 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Native delete
2086591.9 Ops/sec
Deconstruct
3437743.8 Ops/sec
Lodash omit
949117.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
**Benchmark Overview** The provided JSON represents a JavaScript microbenchmark test created on MeasureThat.net. The test compares the performance of three approaches to remove or modify properties from an object: 1. Lodash `omit` method 2. Native JavaScript `delete` operator 3. Object destructuring (Deconstruct) **Options Compared** * **Lodash `omit`**: Uses the `_.omit` function from the Lodash library to create a new object with the specified property removed. + Pros: Simple and concise, widely used, and well-maintained. + Cons: Requires an external dependency (Lodash), might be slower than native methods due to overhead. * **Native JavaScript `delete` operator**: Uses the `delete` operator to remove a property from the object. + Pros: Fast, lightweight, and doesn't require any dependencies. + Cons: Can lead to unexpected behavior if used with certain data types or in specific contexts. * **Object destructuring (Deconstruct)**: Uses object destructuring syntax to create a new object with the specified property removed. + Pros: Modern, concise, and easy to read. + Cons: Might be slower than native methods due to parsing overhead. **Library - Lodash** Lodash is a popular JavaScript utility library that provides a wide range of functions for tasks like string manipulation, array operations, and object transformations. The `omit` function is part of this library and returns a new object with the specified property removed. **JavaScript Features and Syntax** * **Object Destructuring (Deconstruct)**: Introduced in ECMAScript 2015 (ES6), object destructuring allows you to extract properties from objects into variables. In this benchmark, it's used to create a new object with the `meta` property removed. + Pros: Modern, concise, and easy to read. + Cons: Might be slower than native methods due to parsing overhead. **Benchmark Result Interpretation** The latest benchmark result shows the performance of each approach across multiple executions per second. The results indicate that: * Lodash `omit` is the fastest approach (highest executions per second). * Object destructuring (Deconstruct) is the second-fastest approach. * Native JavaScript `delete` operator is the slowest approach. **Other Alternatives** For removing properties from objects, other alternatives to these approaches include: * Using a `for...in` loop with `delete` to remove properties * Utilizing a library like Underscore.js (similar to Lodash) * Implementing custom logic for property removal Keep in mind that the choice of approach depends on your specific use case, performance requirements, and personal preference.
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?