Run details:
Mozilla/5.0 (iPhone; CPU iPhone OS 18_3_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/136.2 Mobile/15E148 Safari/605.1.15
Mobile Safari 18
iOS 18.3.2
Mobile
24 days ago
Test name Executions per second
array[0] 76786.6 Ops/sec
set / get 75136.3 Ops/sec
Script Preparation code:
x
 
// Setup phase - common for both tests
const size = 10000;
const array = new Array(16).fill(1); // Fill array with ones for consistency
const obj = {
    get x() {
        return array[0];
    },
    set x(value) {
        array[0] = value;
    }
};
Tests:
  • array[0]

     
    let sum = 0;
    for (let i = 0; i < size; i++) {
        array[0] = Math.random () * 1000;
        sum += array[0];
    }
  • set / get

     
    let sum = 0;
    for (let i = 0; i < size; i++) {
        obj.x = Math.random () * 1000;
        sum += obj.x;
    }