Test case details

Preparation Code

let array = Array.from({length: 10000}, (_e, i) => i); // big number to prevents browser cache let array2 = array.map( e => { return {obj: e} }); let array3 = new Array(array.length).fill( (i) => array[i] ) at = (array, idx) => { let val = array2[idx]; if( val !== undefined && val.obj === array[idx]) return val // we should make the lazy conversion here // but that wouldn't be fair. throw 'not implemented' }; at2 = (array, idx) => { return array2[idx] // if you already use one }; function update(_array, _i) { throw new Error('Not implemented !') }

Test cases

Test #1

for(let i = 0; i < array.length; ++i) array[i]

Test #2

for(let i = 0; i < array.length; ++i) at(array, i);

Test #3

for(let i = 0; i < array.length; ++i) at2(array, i);

Test #4

for(let i = 0; i < array.length; ++i) array3[i]?.(i) ?? update(array3, i); // reuse the lamba to gain perf on construction

Test #5

for(let i = 0; i < array.length; ++i) array.at(i)