Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Lodash omit Vs. es6 rest spread
(version: 0)
Comparing performance of:
Lodash Omit vs ES6 spread
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.5/lodash.min.js'></script>
Script Preparation code:
var n = 10000; var o = {}; while (n) { o["entry"+ n] = true; n--; }
Tests:
Lodash Omit
_.omit(o, "entry1", "entry2", "entry3", "entry4", "entry5", "entry6", "entry7", "entry8", "entry9", "entry10");
ES6 spread
const {entry1, entry2, entry3, entry4, entry5, entry6, entry7, entry8, entry9, entry10, ...props} = o;
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Lodash Omit
ES6 spread
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
3 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.1 Safari/605.1.15
Browser/OS:
Safari 26 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Lodash Omit
899.4 Ops/sec
ES6 spread
1825.3 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
Let's break down the provided benchmark definition and test cases. **Benchmark Definition** The benchmark is comparing two approaches to omit certain properties from an object: 1. Using Lodash's `omit` function: ```javascript _.omit(o, "entry1", "entry2", ...); ``` This function creates a new object that includes all the properties of `o` except those specified in the array. 2. Using ES6 spread operator (`...props`) to omit properties: ```javascript const { entry1, entry2, ..., props } = o; ``` In this approach, the spread operator is used to extract all properties from `o` into an object called `props`, except for the ones specified in the array. **Options Compared** The two options being compared are: * Lodash's `omit` function * ES6 spread operator (`...props`) **Pros and Cons of Each Approach** ### Lodash's `omit` Function Pros: * Simple to use: Just pass an array of property names to omit. * Fast: Optimized for performance. Cons: * Not native JavaScript: Requires the Lodash library, which may not be available in all environments. * May require additional setup: The benchmark requires a global Lodash variable (`lodash`) to be set up before running the test. ### ES6 Spread Operator Pros: * Native JavaScript: No external libraries required. * Simple and concise syntax: Easy to read and write. Cons: * Performance overhead: The spread operator can create temporary objects, which may incur performance penalties. **Other Considerations** * Memory usage: Both approaches may have different memory footprints, with the `omit` function potentially using more memory due to the creation of a new object. * Browser support: Both approaches are likely supported by most modern browsers. However, older browsers might not support the ES6 spread operator. **Library Used (Lodash)** The Lodash library is a popular JavaScript utility library that provides a wide range of functions for tasks such as array manipulation, object creation, and more. In this benchmark, the `omit` function is used to filter out certain properties from an object. **Special JS Feature/Syntax** There are no special JavaScript features or syntaxes being tested in this benchmark. Both approaches use standard JavaScript syntax and libraries (Lodash for the first approach).
Related benchmarks:
uniqBy performance
lodash vs es6 map
uniqBy performance ttt
lodash omit vs spread omit modified
uniqBy performance lodash vs native
Comments
Confirm delete:
Do you really want to delete benchmark?