Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
&& vs optional chaining
How to better null-check
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36
Browser:
Chrome 125
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
&&
11102942.0 Ops/sec
optional chaining (?.)
20388274.0 Ops/sec
Script Preparation code:
var 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" ] } }
Tests:
&&
if (job.tags && job.tags.export_id) { // do nothing }
optional chaining (?.)
if (job.tags?.export_id) { // do nothing }