Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:108.0) Gecko/20100101 Firefox/108.0
Firefox 108
Windows
Desktop
2 years ago
Test name Executions per second
[i] 6.0 Ops/sec
.at(i) 3.3 Ops/sec
?.[i] 2.9 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];
    }