Skip to main content


Disallow iterating over an array with a for-in loop.


This rule requires type information to run.

A for-in loop (for (var i in o)) iterates over the properties of an Object. While it is legal to use for-in loops with array types, it is not common. for-in will iterate over the indices of the array as strings, omitting any "holes" in the array.

module.exports = {
"rules": {
"@typescript-eslint/no-for-in-array": "error"
Try this rule in the playground ↗


declare const array: string[];

for (const i in array) {

for (const i in array) {
console.log(i, array[i]);


This rule is not configurable.

When Not To Use It

If you want to iterate through a loop using the indices in an array as strings, you can turn off this rule.