Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
bechn Spread operator VS Object.assign VS Object.create vs new Object
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/120.0.0.0 Safari/537.36
Browser:
Chrome 120
Operating system:
Linux
Device Platform:
Desktop
Date tested:
2 years ago
Benchmark engine:
Benchmark.js
Test Spread operator
1.2M/s
Test Object.assign
1.1M/s
Test New Object
721K/s
Test Object.create
462K/s
View exact numbers
Test name
Executions per second
✓
Test Spread operator
1,178,623 Ops/sec
Test Object.assign
1,083,979 Ops/sec
Test New Object
721,383 Ops/sec
Test Object.create
462,050 Ops/sec
Script Preparation code:
for (i = 0; i < 10; i++) { }
Tests:
Test Spread operator
class firstObject { constructor() { this.sampleData = 'Hello world', this.sampleMethod = () => { return true; } } }; const secondObject = {...firstObject}; Object.setPrototypeOf(secondObject, Object.getPrototypeOf(firstObject));
Test Object.create
class firstObject { constructor() { this.sampleData = 'Hello world', this.sampleMethod = () => { return true; } } }; const secondObject = Object.create(Object.getPrototypeOf(firstObject), Object.getOwnPropertyDescriptors(firstObject));
Test Object.assign
class firstObject { constructor() { this.sampleData = 'Hello world', this.sampleMethod = () => { return true; } } }; const secondObject = Object.assign({}, firstObject); Object.setPrototypeOf(secondObject, Object.getPrototypeOf(firstObject));
Test New Object
class firstObject { constructor() { this.sampleData = 'Hello world', this.sampleMethod = () => { return true; } } }; const secondObject = new firstObject();