Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Lodash omit vs es omit vs compiled omit vs rest and delete omit vs babel
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36
Browser:
Chrome 143
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
4 months ago
Test name
Executions per second
Lodash
1525349.6 Ops/sec
es omit
2942495.8 Ops/sec
compiled omit
6030033.5 Ops/sec
rest and delete omit
6179846.0 Ops/sec
babel
8954112.0 Ops/sec
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script> <script src=''> </script>
Script Preparation code:
var omit1 = (originalObj = {}, keysToOmit = []) => Object.fromEntries( Object.entries(originalObj) .filter(([key]) => !keysToOmit.includes(key)) ) var omit2 = new Function('obj', 'if (!obj) return {}; const { a, d, i, ...res } = obj; return res;'); var omit3 = (originalObject = {}, keysToOmit = []) => { const clonedObject = { ...originalObject }; for (const path of keysToOmit) { delete clonedObject[path] } return clonedObject; } function omit4(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
Tests:
Lodash
const obj = { a:1, b:1, c:1, d:1, e:1, f:1, g:1, h:1, i:1, } const n = _.omit(obj, ['a','d','i']);
es omit
const obj = { a:1, b:1, c:1, d:1, e:1, f:1, g:1, h:1, i:1, } const n = omit1(obj, ['a','d','i']);
compiled omit
const obj = { a:1, b:1, c:1, d:1, e:1, f:1, g:1, h:1, i:1, } const n = omit2(obj, ['a','d','i']);
rest and delete omit
const obj = { a:1, b:1, c:1, d:1, e:1, f:1, g:1, h:1, i:1, } const n = omit3(obj, ['a','d','i']);
babel
const obj = { a:1, b:1, c:1, d:1, e:1, f:1, g:1, h:1, i:1, } const n = omit4(obj, ['a','d','i']);