Test name | Executions per second |
---|---|
Object.assign two objects | 47612.7 Ops/sec |
Spread two objects | 44886.8 Ops/sec |
window.object1 = {};
window.object2 = {};
function makeid() {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < 5; i++)
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
};
function populate(object) {
for (let i = 0; i < 100; i++) {
object[makeid()] = makeid();
}
};
populate(object1);
populate(object2);
let object7 = Object.assign({}, object1);
object7 = Object.assign(object7, object2);
const object7 = Object.assign({}, object1);
const object8 = {object7, object2};