How to Get the Index in a forEach Loop in TypeScript
To get the index in a forEach loop in TypeScript, take the second parameter of the callback: items.forEach((item, index) => …). The index is a number, it starts at 0, and you do not have to declare its type because TypeScript infers it from the array. For numbering that people read, use index + 1. … Read more >>









