Test name | Executions per second |
---|---|
Test Spread operator | 880072.1 Ops/sec |
Test Object.create | 455075.4 Ops/sec |
Test Object.assign | 961230.9 Ops/sec |
Test New Object | 460826.4 Ops/sec |
for (i = 0; i < 10; i++) {
}
class firstObject {
constructor() {
this.sampleData = 'Hello world',
this.sampleMethod = () => { return true; }
}
};
const secondObject = {firstObject};
Object.setPrototypeOf(secondObject, Object.getPrototypeOf(firstObject));
class firstObject {
constructor() {
this.sampleData = 'Hello world',
this.sampleMethod = () => { return true; }
}
};
const secondObject = Object.create(Object.getPrototypeOf(firstObject), Object.getOwnPropertyDescriptors(firstObject));
class firstObject {
constructor() {
this.sampleData = 'Hello world',
this.sampleMethod = () => { return true; }
}
};
const secondObject = Object.assign({}, firstObject);
Object.setPrototypeOf(secondObject, Object.getPrototypeOf(firstObject));
class firstObject {
constructor() {
this.sampleData = 'Hello world',
this.sampleMethod = () => { return true; }
}
};
const secondObject = new firstObject();