Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
Object.assign vs spread operator vs property accessor 2
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:124.0) Gecko/20100101 Firefox/124.0
Browser:
Firefox 124
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
property accessor
10.3M/s
property accessor 2
1.7M/s
Object.assign
1.6M/s
spread operator
1.1M/s
View exact numbers
Test name
Executions per second
✓
property accessor
10,265,427 Ops/sec
property accessor 2
1,732,090 Ops/sec
Object.assign
1,610,539 Ops/sec
spread operator
1,097,153 Ops/sec
Script Preparation code:
var arr = [...Array(10).keys()]; var alphabet = [...'abcdefghijklmnopqrstuvwxyz'];
Tests:
Object.assign
arr.reduce((acc, cur) => Object.assign(acc, { [alphabet[cur]]: cur }), {});
spread operator
arr.reduce((acc, cur) => ({ ...acc, [alphabet[cur]]: cur }), {});
property accessor
arr.reduce((acc, cur) => { acc[alphabet[cur]] = cur; return acc; }, {});
property accessor 2
arr.reduce((acc, cur) => { return (acc[alphabet[cur]] = cur); }, {});