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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Browser:
Chrome 121
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
&&
11024081.0 Ops/sec
optional chaining (?.)
22089872.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 }