ipairs

function* ipairs<T>(arr: T[]): IterableIterator<[number, T]

Returns an iterator that yields pairs of indices and values from an sorted array.

const unsortedArr = ['c', 'a', 'b'];
for (const [i, val] of Utils.ipairs(unsortedArr)) {
   console.log(i, val); // [0, 'a'], [1, 'b'], [2, 'c']
} 
Parameter
Type
Optional
Description

arr

T[]

The array to iterate over

Last updated