Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Direct vs optional chaining fixed
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/120.0.0.0 Safari/537.36
Browser:
Chrome 120
Operating system:
Windows
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
All details direct
1242034.2 Ops/sec
All details optional
1944864.1 Ops/sec
Script Preparation code:
var detail1 = null var detail2 = {prop1: 'asdf', prop2: null} var detail3 = {prop1: null, prop2: 'asdf'} var detail4 = {prop1: 'asdf', prop2: 'asdf'} var detail5 = {prop1: null, prop2: null}
Tests:
All details direct
let y1 = detail1 && detail1.prop1 && detail1.prop2 let y2 = detail2 && detail2.prop1 && detail2.prop2 let y3 = detail3 && detail3.prop1 && detail3.prop2 let y4 = detail4 && detail4.prop1 && detail4.prop2 let y5 = detail5 && detail5.prop1 && detail5.prop2
All details optional
let y1 = detail1?.prop1 && detail1?.prop2 let y2 = detail2?.prop1 && detail2?.prop2 let y3 = detail3?.prop1 && detail3?.prop2 let y4 = detail4?.prop1 && detail4?.prop2 let y5 = detail5?.prop1 && detail5?.prop2