Run details:
Mozilla/5.0 (Android 13; Mobile; rv:108.0) Gecko/108.0 Firefox/108.0
Firefox Mobile 108
Android
Mobile
2 years ago
Test name Executions per second
[i] 6.0 Ops/sec
.at(i) 4.2 Ops/sec
?.[i] 4.5 Ops/sec
Script Preparation code:
AخA
 
var a = Array(100_000_000).fill(1);
Tests:
  • [i]

     
    let total = 0;
    for (let i = 0; i < a.length; i++) {
      total += a[i];
    }
  • .at(i)

     
    let total = 0;
    for (let i = 0; i < a.length; i++) {
      total += a.at(i);
    }
  • ?.[i]

     
    let total = 0;
    for (let i = 0; i < a.length; i++) {
      total += a?.[i];
    }