Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
spread operator vs...
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:128.0) Gecko/20100101 Firefox/128.0
Browser:
Firefox 128
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
spread
18451568.0 Ops/sec
lodash
4043407.0 Ops/sec
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/lodash/4/lodash.min.js"></script>
Script Preparation code:
function translateBySpread (a) { const b = { ...(a.id ? { id: a.id } : {}), ...(a.foo ? { foo: a.foo} : {}) } return b; } function translateByLodash (a) { const b = { id: a.id || null, foo: a.foo || null } return _.pickBy(b, !_.isNull); }
Tests:
spread
translateBySpread({ id: '12345', type: 'article' });
lodash
translateByLodash({ id: '12345', type: 'article' });