Run details:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Chrome 121
Linux
Desktop
one year ago
Test name Executions per second
spread 73.3 Ops/sec
non spread 2253.1 Ops/sec
Script Preparation code:
x
 
    var rows = []
    for (let i = 0; i < 10000; i++) {
        rows.push(i)
    }
Tests:
  • spread

     
        var res = rows.reduce(
            (acc, curr) => ({
                ...acc,
                [curr]: curr,
            }),
            {}
        )
  • non spread

     
        var res = {}
        for (let i = 0; i < rows.length; i++) {
            res[i] = i
        }