Tests:
  • if condition

    x
     
    const x = {
        foo: []
    };
    const keys = ["foo", "bar"];
    for (const key of keys) {
      if (!Object.prototype.hasOwnProperty.call(x, key)) {
        x[key] = [];
      }
    }
  • self-assignment

     
    const x = {
        foo: []
    };
    const keys = ["foo", "bar"];
    for (const key of keys) {
      x[key] = x[key] ?? [];
    }
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    if condition
    self-assignment

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: one year ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36
Chrome 114 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
if condition 7527238.0 Ops/sec
self-assignment 31347188.0 Ops/sec