if statements vs optional chaining (v2)

Revision 2 of this benchmark created on


Setup

const job = {
  "summary": {
    "total_actions": 4,
    "finished_actions": 4
  },
  "updated_at": "2020-07-15T10:24:42.364000000Z",
  "job_id": "4b1733e7-c8e0-4fdd-a7f1-13d3ab725c92",
  "description": "Job from our export",
  "created_at": "2020-07-15T10:24:40.975000000Z",
  "status": "finished",
  "tags": {
    "export_id": [
      "8848c5d8-fd44-43c0-b7f2-1428d0f4891a" 
    ]
  }
}

Test runner

Ready to run.

Testing in
TestOps/sec
if statements
if (job.tags && job.tags.export_id) {
    // do nothing
}
ready
optional chaining
if (job.tags?.export_id) {
    // do nothing
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.