Test name | Executions per second |
---|---|
reduce | 3250.4 Ops/sec |
map + fromEntries | 1361.4 Ops/sec |
for loop | 3337.8 Ops/sec |
var data = Array.from(Array(10000).keys());
Object.entries(data).reduce((acc, [k, v]) => {
acc[k] = v.toString();
return acc;
}, {});
Object.fromEntries(Object.entries(data).map(([k, v]) => ([k, v.toString()])));
const dataObject = Object.entries(data)
const acc = {}
for (let i = 0; i < dataObject.length; i++) {
const [k, v] = dataObject[i];
acc[k] = v.toString()
}