---
title: "Discussion on \"Code Smell 53 - Explicit Iteration\" | Hashnode"
description: "Discussion on \"Code Smell 53 - Explicit Iteration\". Iterators are a code smell. We shouldn't use indices while iterating. Prefer higher level collections."
url: "https://hashnode.com/posts/code-smell-53-explicit-iteration/5ff3d9ace8e57e1374e68399"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Code Smell 53 - Explicit Iteration](https://maximilianocontieri.com/code-smell-53-explicit-iteration?utm_source=hashnode&utm_medium=feed)

Iterators are a code smell. We shouldn't use indices while iterating. Prefer higher level collections.

Jan 5, 2021 · 2 min read · maximilianocontieri.com  
Updated Jun 13, 2021  
Read the article

-   [#programming](https://hashnode.com/tag/programming)
-   [#design-patterns](https://hashnode.com/tag/design-patterns)
-   [#clean-code](https://hashnode.com/tag/clean-code)
-   [#2articles1week](https://hashnode.com/tag/2articles1week)
-   [#code-smell-1](https://hashnode.com/tag/code-smell-1)

## Written by

[Maxi Contieri](https://hashnode.com/@mcsee)

@mcsee · Buenos Aires

  
[View profile](https://hashnode.com/@mcsee)

Software Engineer

I’m a senior software engineer loving clean code, and declarative designs. S.O.L.I.D. and agile methodologies fan.

## Responses 1

Markdown supported · ⌘↵ to post

[Chris Bongers](https://hashnode.com/@dailydevtips)

[Jan 5, 2021](https://hashnode.com/posts/code-smell-53-explicit-iteration/5ff3d9ace8e57e1374e68399/comment/5ff41d43fc8177134fbb4bf7)

Nice one!

I do wonder some times I favor a basic for i++ loop since forEach is not 100% browser supported.

What's your take on that?

[Maxi Contieri](https://hashnode.com/@mcsee)

[Jan 5, 2021](https://hashnode.com/posts/code-smell-53-explicit-iteration/5ff3d9ace8e57e1374e68399/comment/5ff41d43fc8177134fbb4bf7#reply-5ff4638ce8e57e1374e68ddd)

An implicit prerequisite is that the code must work.

So a beautiful and declarative not working foreach is not a choice having a working explicit i++

The code must always work. If you have evidence some browsers does not support the declarative one i am ok with the old way.

Shame on browser compatibility

[Chris Bongers](https://hashnode.com/@dailydevtips)

[Jan 5, 2021](https://hashnode.com/posts/code-smell-53-explicit-iteration/5ff3d9ace8e57e1374e68399/comment/5ff41d43fc8177134fbb4bf7#reply-5ff475a1e8e57e1374e68f1d)

[Maxi Contieri](https://hashnode.com/@mcsee) That makes sense, thanks for explaining

And yes, shame on browser compatibility!
