---
title: "Discussion on \"H2H: For-loop search vs the .indexOf() method\" | Hashnode"
description: "Discussion on \"H2H: For-loop search vs the .indexOf() method\". Searching for a specific element in an array is a common task in programming. Two popular methods for searching arrays in JavaScript are iterating over each element using a for loop and Array.prototype.indexOf(). The former is a simple search algorit..."
url: "https://hashnode.com/posts/h2h-for-loop-search-vs-the-indexof-method/6464395db98e36798fd0cea0"
---

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

Discussion

# [H2H: For-loop search vs the .indexOf() method](https://amusiku.hashnode.dev/h2h-for-loop-search-vs-the-indexof-method?utm_source=hashnode&utm_medium=feed)

Searching for a specific element in an array is a common task in programming. Two popular methods for searching arrays in JavaScript are iterating over each element using a for loop and Array.prototype.indexOf(). The former is a simple search algorit...

May 17, 2023 · 6 min read · amusiku.hashnode.dev  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#indexof](https://hashnode.com/tag/indexof)
-   [#for-loop](https://hashnode.com/tag/for-loop)
-   [#arrays](https://hashnode.com/tag/arrays)
-   [#performance](https://hashnode.com/tag/performance)

## Written by

[Austin Musiku](https://hashnode.com/@amusiku)

@amusiku

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

Bootleg senior staff engineer

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
