frankframework / frontend-conventions

1 stars 0 forks source link

Use `for...of` if possible instead of `for index` #4

Open philipsens opened 4 months ago

philipsens commented 4 months ago

The for...of statement can often be used instead of a C style for index. The C style for should only be used if there isn't anything to iterate over. Like when you have a list of non-corresponding items or if there are a number of steps defined in a variable.

Matthbo commented 4 months ago

Add explanation about for..in too since either one can be used based on if you want the key or the value of an object or based on iterator type.

As explanation to why its better, we can take inspiration from eslint-unicorn/no-for-loop