Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
Merge objects with spread vs foreach & new
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
Browser:
Chrome 115
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Benchmark engine:
Benchmark.js
Spread object
20.1M/s
forEach & new
6.0M/s
View exact numbers
Test name
Executions per second
✓
Spread object
20,076,260 Ops/sec
forEach & new
5,960,717 Ops/sec
Script Preparation code:
var a = {'a': 10, 'b': 20, 'c': 30}; var b = {'b': 21, 'c': 31};
Tests:
Spread object
var c = {...a, ...b};
forEach & new
var c = {} Object.keys(a).forEach(k => c[k] = a[k]); Object.keys(b).forEach(k => c[k] = b[k]);