Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
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 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0
Browser:
Firefox 128
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Test Spread operator
2569240.5 Ops/sec
Test Object.create
645643.4 Ops/sec
Test Object.assign
3022232.0 Ops/sec
Test New Object
662436.6 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();