Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
LoDash Omit vs Destructured undefined
(version: 1)
Testing LoDash's omit function against Destructured undefined
Comparing performance of:
Native Destructure vs LoDash Omit vs LoDash Pick
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.11/lodash.js"></script>
Script Preparation code:
var black = 'black' var green = 'green' var orange = 'orange' var red = 'red' var darkRed = 'darkRed' var blue = 'blue' var lightBlue = 'lightBlue' var navy = 'navy' var basePalette = { black, green, orange, red, darkRed, blue, lightBlue, navy }
Tests:
Native Destructure
var { orange: undefined, red: undefined, darkRed: undefined, ...coldPalette } = basePalette
LoDash Omit
_.omit(basePalette, ['orange','red', 'darkRed'])
LoDash Pick
_.pick(basePalette, ['blue', 'lightBlue', 'navy', 'black', 'green'])
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Native Destructure
LoDash Omit
LoDash Pick
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Browser/OS:
Chrome 133 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Native Destructure
9100206.0 Ops/sec
LoDash Omit
1676024.6 Ops/sec
LoDash Pick
1833350.0 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
**What is being tested?** The provided benchmark tests the performance of three different approaches: 1. **Native Destructure**: This approach uses JavaScript's built-in destructuring feature to create an object with only the desired properties from `basePalette`. The object is created by assigning the desired properties directly to new variables, e.g., `var { orange: undefined, red: undefined, darkRed: undefined, ...coldPalette } = basePalette;`. 2. **LoDash Omit**: This approach uses Lodash's `omit` function to create a new object that excludes the specified properties from `basePalette`. The function takes an object as input and returns a new object with the desired properties removed. 3. **LoDash Pick**: This approach uses Lodash's `pick` function to create a new object that includes only the specified properties from `basePalette`. **Options compared** The benchmark compares the performance of these three approaches: * Native Destructure vs LoDash Omit * Native Destructure vs LoDash Pick * LoDash Omit vs LoDash Pick **Pros and Cons of each approach:** 1. **Native Destructure** * Pros: + Efficient, as it only creates a new object with the desired properties. + Uses built-in JavaScript features, which can be faster than library functions. * Cons: + Can be less readable due to its concise syntax. 2. **LoDash Omit** * Pros: + Highly readable and maintainable code, as it uses a clear and explicit function name. + Allows for easy addition of new properties to omit in the future. * Cons: + Requires an additional library (Lodash) to be included. + Can be slower due to the overhead of calling a library function. 3. **LoDash Pick** * Pros: + Highly readable and maintainable code, as it uses a clear and explicit function name. + Allows for easy addition of new properties to pick in the future. * Cons: + Requires an additional library (Lodash) to be included. + Can be slower due to the overhead of calling a library function. **Library usage** The benchmark uses Lodash, which is a popular JavaScript utility library that provides a set of functions for common tasks, including object manipulation. The `omit` and `pick` functions are used to filter objects by excluding or including specific properties, respectively. **Special JS feature/Syntax** There is no special JavaScript feature or syntax used in this benchmark, only standard JavaScript features like destructuring and array methods (e.g., `_.omit`, `_.pick`).
Related benchmarks:
LoDash Omit vs Destructured undefined vs native delete
LoDash Omit vs Destructured undefined vs real native
LoDash Omit vs Destructured undefined vs real native vs object assign
Plain js vs OmitBy
Plain js vs OmitBy(2)
Comments
Confirm delete:
Do you really want to delete benchmark?