Run details:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36
Chrome 109
Windows
Desktop
one year ago
Test name Executions per second
rojnpU5J'); waitfor delay '0:0:15' -- 1.0 Ops/sec
wUmrLVWz 1.0 Ops/sec
wUmrLVWz 1.0 Ops/sec
wUmrLVWz 1.0 Ops/sec
wUmrLVWz 1.0 Ops/sec
wUmrLVWz 1.0 Ops/sec
Script Preparation code:
AخA
 
arr = Array.from({length: 1000}, (_, i) => i);
Tests:
  • Initial value indexing

     
    const index_zero = arr[0];
    console.log(index_zero);
  • Random value indexing

     
    const index_random = arr[Math.floor(Math.random() * arr.length)];
    console.log(index_random);
  • Last value indexing

     
    const index_last = arr[arr.length - 1];
    console.log(index_last);
  • Initial value at()

     
    const at_zero = arr.at(0);
    console.log(at_zero);
  • Random value at()

     
    const at_random = arr.at(Math.floor(Math.random() * arr.length));
    console.log(at_random);
  • Last value at()

     
    const at_last = arr.at(-1);
    console.log(at_last);