Get indexes of array as number, in a for...in loop (Typescript)

1.2k Views Asked by At

A for..in loop in JavaScript, iterates over the keys of the object passed in, and in case of an array iterates over the indexes of the array. Until Typescript 1.7 the index's type was a number but as from Typescript 1.8, index is a string! So I have a function that takes the index as a number and now I need to parse the index to a number like this +index.

Is this the recommended way or there is another way (in Typescript 1.8) to iterate over indexes of the array as numbers instead of strings?

0

There are 0 best solutions below